SqlCommand cmd = new SqlCommand("NParamSP", conn );
cmd.CommandType = CommandType.StoredProcedure;SqlParameter paramRet = cmd.Parameters.Add("@ProductExists", SqlDbType.Int );
paramRet.Value= ParameterDirection.ReturnValue; try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch
{
throw;
}
finally
{
conn.Close()
}
int getret=(int)paramRet.Value }未经验证
cmd.CommandType = CommandType.StoredProcedure;SqlParameter paramRet = cmd.Parameters.Add("@ProductExists", SqlDbType.Int );
paramRet.Value= ParameterDirection.ReturnValue; try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch
{
throw;
}
finally
{
conn.Close()
}
int getret=(int)paramRet.Value }未经验证
解决方案 »
- 时间段比较有没有好方法
- 弱弱的问下,啥是存储过程。
- API读写设备在 多线程中句柄无效!亟待高手指点!
- 同一个datagridview绑定不同table时动态生成的标题不是按SQL查询的顺序,怎么办?
- windows系统两个不同机器同一个文件为什么修改时间相差一秒
- 求高手帮助看看这段信息是怎么解密
- C#创建WORD对象问题,说我权限不够。
- 上海实习多少钱
- <%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>这里的{0:c}是什么意思?还有什么样的形式?
- 帮帮忙,我有administrator口令,如何拿回文件?在线等回复。
- 拜托各位大虾给指点指点。才入门(在线等待)
- 怎么保护 excel 中的那几个列和那几个 cell,没有可以用的分了,可怜可怜一下
as
declare @RetrueValue int
set @RetrueValue=(select Count(*) from employee)
Return @RetrueValueusing System;
using System.Data;
using System.Data.SqlClient;namespace Test
{
class Class1
{
[STAThread]
static void Main(string[] args)
{ int intReturnValue;
string cnstring ="server=.;database=pubs;uid=sa;pwd=";
SqlConnection cn =new SqlConnection(cnstring);
SqlCommand cmd =new SqlCommand("sp_test",cn);
cmd.CommandType= CommandType.StoredProcedure ; SqlParameter sqlpar=new SqlParameter("@RetrueValue",SqlDbType.Int);
sqlpar.Direction= ParameterDirection.ReturnValue;
cmd.Parameters.Add(sqlpar);
try
{
cn.Open();
intReturnValue=cmd.ExecuteNonQuery();
Console.WriteLine("Store Procedure Retrues Value: {0}",sqlpar.Value); //Store Procedure Retrues Value
Console.ReadLine();
}
catch(System.Exception ex)
{
Console.WriteLine(ex.Message );
Console.ReadLine();
}
finally
{
cn.Close();
}
}
}
}