日期:2014-05-19  浏览次数:20491 次

asp.net中,调用存储过程?
string   constr=System.Configuration.ConfigurationSettings.AppSettings[ "connection "];
SqlConnection   con=new   SqlConnection(constr);
con.Open();

SqlCommand   cmd=new   SqlCommand();
cmd.CommandText= "p_GetUnitsInCustomerDetail ";
cmd.CommandType=System.Data.CommandType.StoredProcedure;

                        SqlDataAdapter   sa=new   SqlDataAdapter( "p_GetUnitsInCustomerDetail ",con);
SqlParameter   pa=new   SqlParameter( "@U_Customer ",System.Data.SqlDbType.VarChar,20);
pa.Value=this.TextBox1.Text;
sa.SelectCommand.Parameters.Add(pa);
DataSet   ds=new   DataSet();
//cmd.Parameters.Add( "@U_Customer ",System.Data.SqlDbType.VarChar,20);
sa.Fill(ds);
this.DataGrid1.DataSource=ds.Tables[0].DefaultView;
this.DataGrid1.DataBind();
  上面是我在asp.net中调用sql2000的一个存储过程,为什么执行后,老提示说:第   1   行:   'p_GetUnitsInCustomerDetail '   附近有语法错误。
这是为什么啊?请大家帮我看看啊~~~

------解决方案--------------------
没有指定commandType
------解决方案--------------------
错了,指定了,好像没有用那个command
------解决方案--------------------
p_GetUnitsInCustomerDetail里边是一条SQL语句吧?语句有错
------解决方案--------------------
SqlDataAdapter sa = new SqlDataAdapter(cmd);
------解决方案--------------------
没使用command
SqlDataAdapter sa=new SqlDataAdapter(cmd,con);