请问高手asp.net中如何调用存储过程
解决方案 »
- Asp.net自定义控件 显示状态切换问题
- 一个Word 操作中的问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- asp.net2005 GridView 查找编辑的控件
- <%#Request.QueryString["aim"]%>为何在页面上面没有数据显示!!
- 哪位老大能提供ComponentOne的注冊碼啊?!
- 能否这样输出路径?
- 怎么把IListSource 中的值赋给DataView (传说标题要长长长……………………)
- 提问关于如何实现如图的功能??解决立刻给分??
- 动网新闻,我放在了,网站根目录的下一级目录,出现这样的问题请问该如何解决?
- 如何注册自定义用户控件
- Microsoft 论坛怎么不能登录了?
- 小小的问题
SqlConnection conn = new SqlConnection(connstring);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;//设置cmd的类型为存储过程
cmd.CommandText = "CustOrderHist";
cmd.Connection = conn; SqlParameter pCustomerID = new SqlParameter();
pCustomerID.ParameterName = "@CustomerID";
pCustomerID.SqlDbType = SqlDbType.NChar;
pCustomerID.Value = "ALFKI"; cmd.Parameters.Add(pCustomerID);
CustOrderHist:存储过程名称,@CustomerID存储过程中的参数。
conn.Open();
SqlCommand MyCommand = new SqlCommand("", conn);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add(new SqlParameter("@a", SqlDbType.Int));
MyCommand.Parameters["@a"].Value = 20;
MyCommand.Parameters.Add(new SqlParameter("@b", SqlDbType.Int));
MyCommand.Parameters["@b"].Value = 20;
MyCommand.Parameters.Add(new SqlParameter("@c", SqlDbType.Int));
MyCommand.Parameters["@c"].Direction = ParameterDirection.Output;
MyCommand.ExecuteNonQuery();
Response.Write(MyCommand.Parameters["@c"].Value.ToString());