c#调用存储过程的问题

hya0114145 2008-08-20 08:48:16

public static int ChiDao(string name, DateTime mintime,DateTime maxtime)
{
try
{
SqlParameter[] par = new SqlParameter[]
{
new SqlParameter("@name",SqlDbType.VarChar).Value=name,
new SqlParameter("@datemin",SqlDbType.DateTime).Value=mintime,
new SqlParameter("@datemax",SqlDbType.DateTime).Value=maxtime,
new SqlParameter("@shuchu",SqlDbType.Int).Direction=ParameterDirection.Output
};
DBHelper.ExecuteCommand("chaxunchidao",par);


}
catch (Exception)
{

throw;
}


public static void ExecuteCommand(string name, SqlParameter[] paramArray)
{
using (conn = new SqlConnection(SqlConn))
{
try
{
command = new SqlCommand();
command.CommandText = name;
command.Connection = conn;
command.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < paramArray.Length; i++)
{
command.Parameters.Add(paramArray[i]);
}
conn.Open();
command.ExecuteNonQuery();
}
catch (Exception e)
{
throw e;
}
}

}

在ChiDao中怎样返回@shuchu的值




...全文
54 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xingboat 2008-08-20
  • 打赏
  • 举报
回复
command.ExecuteNonQuery();後面加
return (int)command.Parameters["@shuchu"].Value;
---樓主可以結貼了。。

Zeteyu 2008-08-20
  • 打赏
  • 举报
回复

return (int)par[3].Value;
amingo 2008-08-20
  • 打赏
  • 举报
回复
执行完后par [2].value
downmoon 2008-08-20
  • 打赏
  • 举报
回复


http://topic.csdn.net/u/20080717/17/7cca1510-c690-48ef-99bd-2991becb86d4.html

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧