stored procedure>cmd>datagridview

thejeraldo

Well-known member
Joined
Jun 9, 2009
Messages
70
Location
Philippines
Programming Experience
1-3
oh well i thought i wouldnt ask for this in this forum but since ive spent like a couple of hours figuring out how to do this and came out of nothing.. well now im asking:

how do execute a stored procedure using a command and then put the results of it in say a dataset?

im just learning how to use stored procedures in vb.net.
my main purpose is to know how i can pass a textbox value to a parameter of the stored procedure then execute it.

thanks a lot!
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,295
Location
Sydney, Australia
Programming Experience
10+
Create the appropriate command object, e.g. SqlCommand. Assign the name of your sproc to the CommandText property and set the CommandType property to StoredProcedure. You then add a parameter to the command exactly as you would for inline SQL statements.

John McIlhinney's .NET Developer Blog: Using Parameters in ADO.NET

If you want to populate a DataTable then that command should be the SelectCommand of a DataAdapter on which you call Fill, or else you can call ExecuteReader on the command and then Load on the DataTable.
 
Top Bottom