请问大虾,c#中如何拿到存储过程的返回值?
SqlConnection sqlconCheckDB=new SqlConnection("server=JW_GU;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand("spName",sqlconCheckDB);//spName是存储过程的名字
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
这一段也是从相关贴子上找到的,怎么哪返回值阿,大家给点简单的的代码,复杂的看不懂,小弟刚开始学!
SqlConnection sqlconCheckDB=new SqlConnection("server=JW_GU;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand("spName",sqlconCheckDB);//spName是存储过程的名字
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
这一段也是从相关贴子上找到的,怎么哪返回值阿,大家给点简单的的代码,复杂的看不懂,小弟刚开始学!
@name varchar(30),
@type varchar(30),
@outtype int
)
as
begin
if @type='db'
begin
if not exists(SELECT * FROM master..sysdatabases WHERE name=@name)
begin
exec('create database '+@name)
select @outtype=1
end
end if @type='tb'
begin
if not exists(SELECT @name FROM sysobjects WHERE name = @name AND type = 'U')
begin
exec('create table '+@name)
select @outtype=2
end
end if @type='pro'
begin
if not exists(SELECT @name FROM sysobjects WHERE name = @name AND type = 'P')
begin
exec('create table '+@name)
select @outtype=3
end
end
return
end
我要在c#程序里面拿到这个存储过程的返回值,怎么拿?请给出代码给小弟看看
param.Direction = ParameterDirection.Output;
param.Value = Value;
/...
)
begin
/......
end
现在我要调用这个存储过程,怎么调用,然后,他返回出来的值,我怎么拿,请那位大虾,给点代码看看,怎么拿值,怎么调用,比如说:存储过程返回的是一个int 型的值,现在付给我程序里的int count变量,怎么写?谢谢大家!我自顶!