reg:stored procedure

S

Satheesh Kumar

how to insert values into stored procedure....
using vb.net application....
if any one knows send me the sample code... for that insert query
 
G

Guest

In C# the answer is

for stored proc like :
-----------------
Create Procedure SelectById
(
@ID int
)
AS

Select * from MyTable Where [ID] = @ID
----------------

the code would be:

string connectionString = "" // Put connection string here
using (SqlConnection conn = new SqlConnection(connectionString)){
using(SqlCommand sqlcom = new SqlCommand("SelectById",conn)){
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.Parameters.Add("@ID",SqlDbType.Int).Value = 1; //the value to
pass in
SqlDataReader reader = sqlcom.ExecuteReader();
//Do something here with results
}
}

HTH - SharpDevelop and convert C# to VB.NET

Ciaran O'Donnell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top