检索参数信息并填充指定的 SqlCommand 对象的 Parameters 集合

        private SqlParameterCollection GetSpParameters(string spName)
        {
            SqlCommand myCommand = new SqlCommand();
            myCommand.CommandText = spName;
            myCommand.CommandType = CommandType.StoredProcedure;
            
            myCommand.Connection = new SqlConnection("user id=sa;password=sa;data source=.;persist security info=True;initial catalog=数据库");
            myCommand.Connection.Open();

            SqlCommandBuilder.DeriveParameters(myCommand);

            return myCommand.Parameters;
        }
原文地址:https://www.cnblogs.com/icebutterfly/p/2184290.html