PDA

View Full Version : سوال: اجرای روال ذخیره شده با دو پارامتر خروجی



moferferi
دوشنبه 05 مرداد 1388, 13:13 عصر
سلام
من یه sp دارم و میخوام که دو مقدار را پس بده
ایا درست نوشتم


ALTER PROCEDURE [dbo].[selectCountfile]
@mycount int output,
@mymax int output
as
declare @mymax2 int
declare @mycount2 int


--select count(intfile) from personfile
select @mycount2 = count(intfile) from personfile
select @mymax2=max(intfile) from personfile

set @mycount=@mycount2
set @mymax=@mymax2
return @mymax
return @mycount

اینم کد سی شارپ

SqlCommand command =
new SqlCommand("selectCountfile", connection);
command.CommandType = CommandType.StoredProcedure;
// Create the output parameter

command.Parameters.Add("@mycount", SqlDbType.Int).Direction =
ParameterDirection.Output;
SqlParameter retParam =
command.Parameters.Add("@mycount", SqlDbType.Int);
retParam.Direction = ParameterDirection.Output;
//----------------------------------------------------
command.Parameters.Add("@mymax", SqlDbType.Int).Direction =
ParameterDirection.Output;
SqlParameter retParam2 =
command.Parameters.Add("@mymax", SqlDbType.Int);
retParam2.Direction = ParameterDirection.Output;
//-----------------------------------------------------
connection.Open();
command.ExecuteNonQuery();
connection.Close();
label1.Text = retParam2.Value.ToString();
label2.Text = retParam.Value.ToString();
کسی میدونه مشکل از کدومه(sp یا سی شارپ)