I
Islamegy®
When i call stored procedure which have an output paramter, t'm unable to
get the value
How could i fix it??
here is the method....
----------------------------
userid = 0;
SqlParameter[] collection = new SqlParameter[]
{
new SqlParameter("@ID",DBNull.Value),
new SqlParameter("@Title", ddl_title.SelectedValue),
new SqlParameter("@Name", txt_Name.Text),
new SqlParameter("@Address", txt_Address.Text),
new SqlParameter("@Tel1", txt_Tel.Text),
new SqlParameter("@Tel2", txt_AltTel.Text),
new SqlParameter("@Fax", txt_Fax.Text),
new SqlParameter("@mobile", txt_Mobile.Text),
new SqlParameter("@City", txt_City.Text),
new SqlParameter("@country", ddl_Country.SelectedValue),
new SqlParameter("@Email", txt_Email.Text),
new SqlParameter("@UserName", txt_UserName.Text),
new SqlParameter("@Password", txt_Password.Text) };
try
{
int x =
SqlHelper.ExecuteNonQuery(connString,CommandType.StoredProcedure,"wsi_Users_Insert",collection);
if (x != 0)
{
userid = int.Parse(collection[0].Value.ToString());
return true;
}
else
return false;
}
catch (SqlException) { return false; }
and here is the procedure
------------------------------
CREATE PROCEDURE dbo.wsi_Users_Insert
(
@ID int OUTPUT,
@Title varchar (10) ,
@Name varchar (100) ,
@Address varchar (500) ,
@Tel1 varchar (15) ,
@Tel2 varchar (15) ,
@Fax varchar (15) ,
@mobile varchar (15) ,
@City varchar (50) ,
@country int ,
@Email varchar (50) ,
@UserName varchar (50) ,
@Password varchar (50)
)
AS
INSERT INTO dbo.[Users]
(
[Title]
,[Name]
,[Address]
,[Tel1]
,[Tel2]
,[Fax]
,[Mobile]
,[City]
,[Country]
,(e-mail address removed)
get the value
How could i fix it??
here is the method....
----------------------------
userid = 0;
SqlParameter[] collection = new SqlParameter[]
{
new SqlParameter("@ID",DBNull.Value),
new SqlParameter("@Title", ddl_title.SelectedValue),
new SqlParameter("@Name", txt_Name.Text),
new SqlParameter("@Address", txt_Address.Text),
new SqlParameter("@Tel1", txt_Tel.Text),
new SqlParameter("@Tel2", txt_AltTel.Text),
new SqlParameter("@Fax", txt_Fax.Text),
new SqlParameter("@mobile", txt_Mobile.Text),
new SqlParameter("@City", txt_City.Text),
new SqlParameter("@country", ddl_Country.SelectedValue),
new SqlParameter("@Email", txt_Email.Text),
new SqlParameter("@UserName", txt_UserName.Text),
new SqlParameter("@Password", txt_Password.Text) };
try
{
int x =
SqlHelper.ExecuteNonQuery(connString,CommandType.StoredProcedure,"wsi_Users_Insert",collection);
if (x != 0)
{
userid = int.Parse(collection[0].Value.ToString());
return true;
}
else
return false;
}
catch (SqlException) { return false; }
and here is the procedure
------------------------------
CREATE PROCEDURE dbo.wsi_Users_Insert
(
@ID int OUTPUT,
@Title varchar (10) ,
@Name varchar (100) ,
@Address varchar (500) ,
@Tel1 varchar (15) ,
@Tel2 varchar (15) ,
@Fax varchar (15) ,
@mobile varchar (15) ,
@City varchar (50) ,
@country int ,
@Email varchar (50) ,
@UserName varchar (50) ,
@Password varchar (50)
)
AS
INSERT INTO dbo.[Users]
(
[Title]
,[Name]
,[Address]
,[Tel1]
,[Tel2]
,[Fax]
,[Mobile]
,[City]
,[Country]
,(e-mail address removed)