日期:2014-05-18  浏览次数:20740 次

高手们。帮忙看一下。。。。。。该一下。。。。。。
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的语句
探讨
command.CommandType = CommandType.Text改成 command.CommandType = CommandType.StoredProcedure;

SqlDataAdapter da = new SqlDataAdapter(command);
2句都要改

------解决方案--------------------
第2,3参数你传都都是null 你看看你sql语句 参数定义的 可不可以为null