sqldatasource如何得到存储过程的返回值 sqldatasource 后台用代码,如何得到存储过程的返回值我的存储过程就是判断是否有这个帐号。有就执行一个 update语句,然后return 1我应该如何用代码实现得到这个返回值。请大家告诉我下,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果你的存储过程是output输出的,即:@ProductID int output返回值调用代码: SqlParameter P_ProductID=new SqlParameter("@ProductID",SqlDbType.Int,4); P_ProductID.Direction=ParameterDirection.Output; myCommand.Parameters.Add(P_ProductID); myConnection.Open(); myCommand.ExecuteNonQuery(); myConnection.Close(); ReturnID=(int)P_ProductID.Value;如果你的返回值不是OUTPUT,而是RETURN的那么用下面的方法: SqlParameter P_ProductID=new SqlParameter("@ProductID",SqlDbType.Int,4); P_ProductID.Value=ProductID; myCommand.Parameters.Add(P_ProductID); myConnection.Open(); ReturnID=myCommand.ExecuteNonQuery(); myConnection.Close(); 要看你用的存储过程对应SqlDataSource的什么属性,我假设是UpdateCommand那么就在SqlDataSource的OnUpdated事件中处理 protected void SqlDataSource_Updated(object sender, SqlDataSourceStatusEventArgs e) { //这里参数的名称取决于你在前台存储过程返回值的名称 //Label1.Text = e.Command.Parameters["@ReturnValue"].Value.ToString(); } dataGridView绑定不了泛型 一个非常郁闷的问题 Socket(AddressFamily addressFamily,SocketType socketType,ProtocolType protocolTy 关于多进程+多线程方式下的线程状态取得(在线等) 怎么让程序最小化后只在任务栏的时间那里出现啊? C#的多重继承导致成员二义性问题 “sendMailTest” : 成员名称不能与它们的封闭类型相同 菜鸟问题:.net是否有分2003版、2002版...? 绑定后怎么修改数据? 请教Socket,数据发送接收问题! c#的错误管理 怎样打印DataGridView
@ProductID int output
返回值调用代码: SqlParameter P_ProductID=new SqlParameter("@ProductID",SqlDbType.Int,4);
P_ProductID.Direction=ParameterDirection.Output;
myCommand.Parameters.Add(P_ProductID); myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close(); ReturnID=(int)P_ProductID.Value;
如果你的返回值不是OUTPUT,而是RETURN的
那么用下面的方法:
SqlParameter P_ProductID=new SqlParameter("@ProductID",SqlDbType.Int,4);
P_ProductID.Value=ProductID;
myCommand.Parameters.Add(P_ProductID); myConnection.Open();
ReturnID=myCommand.ExecuteNonQuery();
myConnection.Close();
{
//这里参数的名称取决于你在前台存储过程返回值的名称
//Label1.Text = e.Command.Parameters["@ReturnValue"].Value.ToString();
}