获得存储过程返回值的方法(return的值)

摘自: http://www.newasp.net/tech/net/9841.html
System.Data.SqlClient.SqlConnection scon = new System.Data.SqlClient.SqlConnection("server=Netangel;uid=etopsUS;pwd=etops;database=etops");
System.Data.SqlClient.SqlCommand scom = new System.Data.SqlClient.SqlCommand("",scon);

scon.Open();
scom.CommandText="p_CorpClassAdd";
scom.CommandType = System.Data.CommandType.StoredProcedure;
scom.Parameters.Add(
                new SqlParameter("ReturnValue", SqlDbType.Int, 4,
                ParameterDirection.ReturnValue, false, 0, 0,
                string.Empty, DataRowVersion.Default, null)) //增加存储过程的返回值参数

scom.ExecuteNonQuery();
Response.Write(scom.Parameters["ReturnValue"].Value.ToString());  //输出存储过程的返回值 

转载于:https://www.cnblogs.com/wj-wangjun/archive/2008/05/23/1205715.html

你可能感兴趣的:(java,数据库)