两种写法如下:
1、不报错写法:
IDbConnection concreteDbConn = new System.Data.SqlClient.SqlConnection();
            concreteDbConn.ConnectionString="Server=127.0.0.1;Database=jcSystemData;User ID=sa;Password=newman2007;Connect Timeout=20;Pooling=True;Min Pool Size=1;Max Pool Size=100;Persist Security Info=False;Asynchronous Processing=true;Integrated Security=false;";
            IDbCommand concreteDbCommand = new System.Data.SqlClient.SqlCommand("Jcp_QueryGoodBaseInfoDefineSelf", (System.Data.SqlClient.SqlConnection)concreteDbConn);            concreteDbCommand.CommandType = CommandType.StoredProcedure;             SqlParameter[] parms ={new SqlParameter ("@v_QryType",SqlDbType.VarChar,100),
                                   new SqlParameter ("@v_QryWhere",SqlDbType.VarChar,100),
                                   new SqlParameter ("@v_ColsScript",SqlDbType.VarChar,100),
                                   new SqlParameter ("@v_UserID ",SqlDbType.VarChar,100)};            parms[0].Direction = ParameterDirection.Input;
            parms[1].Direction = ParameterDirection.Input;
            parms[2].Direction = ParameterDirection.Input;
            parms[3].Direction = ParameterDirection.Input;            parms[0].Value = "N";
            parms[1].Value = "n=对";
            parms[2].Value = "GoodID as 商品编码, ScanCode as  条码编号,GoodName as 商品名称 ,Spec as  规格,Unit as 销售单位,MinPacks as 包装数,AvgCostPric as 商品进价,RetailPric as 零售价格,WholeSalePric as 批发价格,MemPric  as  会员价格,InTaxRate  as  进项税率,SaleTaxRate as   销项税率,LogUnit as 物流单位,LogPacks as  物流包装数,SupTypeID as 大类编码,SupTypeName as 大类名称,MidTypeID as 中类编码,MidTypeName as 中类名称,SmlTypeID as 小类编码,SmlTypeName as 小类名称 ";
            parms[3].Value = "qjc";
            foreach (SqlParameter p in parms)
            {
                concreteDbCommand.Parameters.Add(p);
            }
            concreteDbConn.Open();            
                         IDbDataAdapter objAdapter = new System.Data.SqlClient.SqlDataAdapter() ;            DataSet objDataSet = new DataSet();            try
            {                objAdapter.SelectCommand = concreteDbCommand;
                objAdapter.Fill(objDataSet);
            }
            catch (Exception ex)
            {
                // System.Diagnostics.Debugger.Break();
                throw ex;
            }
            finally
            {
                concreteDbConn.Close();
            }            concreteDbCommand.Parameters.Clear();
2、报错写法(调用微软开源类):
SqlParameter[] parms ={new SqlParameter ("@v_QryType",SqlDbType.VarChar,100),
                                   new SqlParameter ("@v_QryWhere",SqlDbType.VarChar,100),
                                   new SqlParameter ("@v_ColsScript",SqlDbType.VarChar,100),
                                   new SqlParameter ("@v_UserID ",SqlDbType.VarChar,100)};            parms[0].Direction = ParameterDirection.Input;
            parms[1].Direction = ParameterDirection.Input;
            parms[2].Direction = ParameterDirection.Input;
            parms[3].Direction = ParameterDirection.Input;            parms[0].Value = "N";
            parms[1].Value = "n=对";
            parms[2].Value = "GoodID as 商品编码, ScanCode as  条码编号,GoodName as 商品名称 ,Spec as  规格,Unit as 销售单位,MinPacks as 包装数,AvgCostPric as 商品进价,RetailPric as 零售价格,WholeSalePric as 批发价格,MemPric  as  会员价格,InTaxRate  as  进项税率,SaleTaxRate as   销项税率,LogUnit as 物流单位,LogPacks as  物流包装数,SupTypeID as 大类编码,SupTypeName as 大类名称,MidTypeID as 中类编码,MidTypeName as 中类名称,SmlTypeID as 小类编码,SmlTypeName as 小类名称 ";
            parms[3].Value = "qjc";
            DataTable dt = dbacc.ExecuteDataSet("Jcp_QueryGoodBaseInfoDefineSelf ", parms).Tables[0];请问是什么原因呢,我对比了传入的SqlParameter好象都没什么区别,