Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to use input and output parameters

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-02-27 : 12:13:19
Cynthia writes "Hi,
I have c# code where I call stored procedure. I want to pass database connection string and parameter to stored procedure.
I'll do some caluculation and update the table based on Input value I passed. Now the procedure should return the value back.

How Can I go about this problem


Thanx,
Cynthia."

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-02-27 : 16:14:09
Check the BOL (Books OnLine) for Stored Procedures

In the Index type
"stored procedures, output parameters"
and
"Using Return Code and Output Parameters for Stored Procedures"
Go to Top of Page

jimmy_a
Starting Member

38 Posts

Posted - 2006-02-28 : 01:03:59
sqlCmd = new SqlCommand("nat_InsertHotelMessage",sqlCon);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.Add("@msgId",mid);
sqlCmd.Parameters.Add("@msgText",msgText);
if(sname != "Select Set Name")
{
sqlCmd.Parameters.Add("@selectOpn","2");
sqlCmd.Parameters.Add("@setname",sname);
}
if(rid != "Select RoomNo")
{
sqlCmd.Parameters.Add("@selectOpn","1");
sqlCmd.Parameters.Add("@setname",rid);
}
//sqlCmd.Parameters.Add("@roomid",rid);
//sqlCmd.Parameters.Add("@setname",sname);
sqlCmd.Parameters.Add("@service",service);
sqlCmd.Parameters.Add("@freq",freq);
sqlCmd.Parameters.Add("@stat",stat);
sqlCmd.Parameters.Add("@ret_status",SqlDbType.Int);
sqlCmd.Parameters["@ret_status"].Direction = ParameterDirection.Output;
sqlCmd.ExecuteNonQuery();
ret = (int)sqlCmd.Parameters["@ret_status"].Value;
sqlCmd.Dispose();
sqlCmd = null;


"A smile is an inexpensive way to improve your looks"
Go to Top of Page

jimmy_a
Starting Member

38 Posts

Posted - 2006-02-28 : 01:04:34
Hope the above sample will help u

"A smile is an inexpensive way to improve your looks"
Go to Top of Page
   

- Advertisement -