【发布时间】:2014-03-15 10:00:21
【问题描述】:
我想从 SQL Server 中的项目表中检索项目 ID。
我创建了一个这样的存储过程:
create proc spFindProjectID
(@customerid int)
as
begin
select Project.pID
from Project
where Project.cID=@customerid
end
现在在我的 C# 中,我像这样执行该过程:
public int findid(int id)
{
con = connect("igroup9_test1ConnectionString");
using (SqlCommand sqlComm = new SqlCommand("[spFindProjectID]", con))
{
if (con.State != ConnectionState.Open)
{
con.Open();
}
try
{
sqlComm.CommandType = CommandType.StoredProcedure;
sqlComm.Parameters.AddWithValue("@customerid", id);
sqlComm.CommandTimeout = 600;
sqlComm.ExecuteNonQuery();
}
catch (Exception ex)
{
throw (ex);
}
return
}
}
我想保存过程中的结果并返回它。
我该怎么做?
【问题讨论】:
标签: c# asp.net sql-server stored-procedures save