使用企业库调用存储过程,并接受return 的返回值
String sql = "moveData";
mCMD = DB.GetStoredProcCommand(sql);
DB.AddInParameter(mCMD,"@State",DbType.Int32,2);
DB.AddParameter(mCMD, "@ret", DbType.Byte, ParameterDirection.ReturnValue,"",DataRowVersion.Default,null);
mCMD.Parameters["@ret"].Value
1.添加参数
public void AddParameter(DbCommand command, string name, DbType dbType, ParameterDirection direction, string sourceColumn, DataRowVersion sourceVersion, object value);
DB.AddParameter(mCMD, "@return", DbType.Byte, ParameterDirection.ReturnValue,"",DataRowVersion.Default,null);
DB.AddParameter(mCMD, "@return", DbType.Byte, ParameterDirection.ReturnValue,NULL,DataRowVersion.Default,null);
说明:第二个为参数名必须为 @变量名 否则系统会自动添加
ParameterDirection.ReturnValue 最关键指明去传回值
2.执行
DB.ExecuteNonQuery(mCMD);
3.取值
DbType.Byte x= mCMD.Parameters["@return"].Value;
转自:http://www.cnblogs.com/zfh424/archive/2009/02/03/1383507.html