高手们。帮忙看一下。。。。。。该一下。。。。。。
SqlParameter[] parm =
{
new SqlParameter("@CompanyId", SqlDbType.NVarChar,50),
new SqlParameter("@EndTime", SqlDbType.DateTime),
new SqlParameter("@IncludeNoCheckt", SqlDbType.Bit),
};
parm[0].Value = textBox1.Text.Trim().ToString();
parm[1].Value = null;
parm[2].Value = null;
string str = ConfigurationManager.ConnectionStrings["WindowsFormsApplication4.Properties.Settings.qinghaiConnectionString"].ToString();
SqlConnection con = new SqlConnection(str);
con.Open();
SqlCommand command = new SqlCommand();
if (parm != null)
{
foreach (SqlParameter pm in parm)
command.Parameters.Add(pm);
}
command.CommandType = CommandType.Text;
command.CommandText = "Pro_RptPersonTotal";
command.Connection = con;
SqlDataAdapter da = new SqlDataAdapter("Pro_RptPersonTotal", con);
DataTable ds = new DataTable();
da.Fill(ds);
dataGridView1.DataSource = ds;
报错:过程或函数 'Pro_RptPersonTotal' 需要参数 '@CompanyId',但未提供该参数。哪里写错了啊。看不懂。
[解决办法]
不对 这句话问题 command.CommandType = CommandType.Text改成 command.CommandType = CommandType.StoredProcedure;
[解决办法]
SqlDataAdapter da = new SqlDataAdapter(command);
[解决办法]
正解
楼主对存储过程调用不是很熟悉啊,还是用的text的语句