How to call parameterized stored procedure to return result set?

L

Lacka

Hi,

If I have a stored procedure in my database, that has two parameters (say @a
nvarchar(50) and @b int), and returns the result of a SELECT statement
(returns a result set), how can I set up the parameters, how can I call it,
and how can I iterate through the rows of the returned resultset?

thanks,
Lacka
 
K

Karl Seguin

Lacka, I answered how to return iterate through it in your other post, as
for your two other questions:

Dim connection As New SqlConnection("...")
Dim command As New SqlCommand("Your sp name", connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@a", SqlDbType.NVarChar, 50).Value = "some
value"
command.Parameters.Add("@b", SqlDbType.Int).Value = 1
Dim da As New SqlDataAdapter(command)
Try
Dim ds As New DataSet
connection.Open()
da.Fill(ds)
Finally
connection.Dispose()
command.Dispose()
da.Dispose()
End Try
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top