存储过程里有个return @count 是返回查询记录的条数
asp中:
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConStr"]);
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "UserInfo_Select";
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.AddWithValue("@NickName", NickName);
comm.Parameters.AddWithValue("@type", 0);
conn.Open();
int temp= comm.ExecuteNonQuery();
……
我要想获得存储过程里返回的记录条数 该怎么写呢?
asp中:
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConStr"]);
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "UserInfo_Select";
comm.CommandType = CommandType.StoredProcedure;
comm.Parameters.AddWithValue("@NickName", NickName);
comm.Parameters.AddWithValue("@type", 0);
conn.Open();
int temp= comm.ExecuteNonQuery();
……
我要想获得存储过程里返回的记录条数 该怎么写呢?
解决方案 »
- 如何用编码清除SSL状态?
- ibatis连接Oracle 11g,是用asp.net开发的,我用oracleClient1.0连接Oracle 10g可以但11g不行,总是报Unable
- 求一个弹出选择的功能
- 一小段javascript代码出现问题
- url 重写 字母数字混合正则,哪位知道告诉一下@!
- 如何获取当前文件的服务器路径?
- SqlParameter[]的问题。
- 一個有關datagrid的問題﹗馬上結貼﹗﹗﹗
- 帮帮忙看看我这报错的是什么意思?
- VS2010 中新建的asp.net项目,为什么找不到自带页面的前台控件?
- 能不能判断回调函数的执行状态?
- 求图表Zedgraph Web版控件
就跟sql一样
/// 执行Oracle存储过程,
/// </summary>
/// <param name="procedureName">存储过程名称</param>
/// <param name="parameterColl">存储过程参数集合</param>
/// <param name="outField">返回参数</param>
/// <returns></returns>
public static string RunProcedure(string procedureName, OracleParameter[] parameterColl, string outField, OracleConnection conn)
{
string result = ""; try
{
InitDB();//打开数据库连接
OracleCommand cmd = new OracleCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn;
cmd.CommandText = procedureName; foreach (OracleParameter para in parameterColl)
{
cmd.Parameters.Add(para);
}
if (cmd.Connection.State == ConnectionState.Closed)
cmd.Connection.Open(); cmd.ExecuteNonQuery();
cmd.Connection.Close();
result = cmd.Parameters[outField].Value.ToString();
}
catch (Exception ex)
{
BusinessLogical.Error.SystemLog.WriteLog("RunProcedure() " + ex.Message + " " + ex.Source);//写日志
}
return result; }
给存储过程加了个参数
comm.Parameters.Add(new SqlParameter("ReturnValue",
SqlDbType.Int, 4, ParameterDirection.ReturnValue,
false, 0, 0, string.Empty, DataRowVersion.Default, null));
接收参数
int result = (int)comm.Parameters["ReturnValue"].Value;谢各位~