p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional C#, 2nd and 3rd Editions (http://p2p.wrox.com/forumdisplay.php?f=44)
-   -   Sql server Stored procedure (http://p2p.wrox.com/showthread.php?t=13496)

ranakdinesh May 27th, 2004 09:04 AM

Sql server Stored procedure
 
i have a procedure in Sql Server named ADDItem. which accepts four parameters and then save them in the database table employee.how i can call that procedure and pass parameters using C# and ADo. net

dinesh Rana

bmains May 27th, 2004 03:21 PM

SQLConnection cn = New SQLConnection(strConnectionString);
SQLDataAdapter adp = New SQLDataAdapter;
adp.InsertCommand = New SQLCommand("ADDItem", cn);

adp.InsertCommand.Parameters.Add("@Param1", SQLDbType.VarChar, 10).Value = strValue;
... repeat 3 times ...

cn.Open();
adp.InsertCommand.ExecuteNonQuery();
cn.Close();

Something like that.

Brian

melvik May 29th, 2004 12:08 AM

if u use SqlCommandObj & set that in visual useing VS.NET Tolls u only to set its Params like;

Code:

SqlConn.Open();
SqlCommandObj.Parameters["@Param1"].Value = Param1;
SqlCommandObj.Parameters["@Param2"].Value = Param2;
SqlCommandObj.Parameters["@Param3"].Value = Param3;
SqlCommandObj.Parameters["@Param4"].Value = Param4;
SqlCommandObj.ExecuteReader();
SqlConn.Close();

Always:),
Hovik Melkomian.


All times are GMT -4. The time now is 07:59 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.