How to call parameterized stored procedure to return result set?

Discussion in 'ASP .Net' started by Lacka, Dec 31, 2004.

  1. Lacka

    Lacka Guest

    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
    Lacka, Dec 31, 2004
    #1
    1. Advertising

  2. Lacka

    Karl Seguin Guest

    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

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Lacka" <> wrote in message
    news:en%...
    > 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
    >
    >
    Karl Seguin, Dec 31, 2004
    #2
    1. Advertising

  3. Lacka

    Lacka Guest

    Thanks!
    Lacka, Dec 31, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neo Chou
    Replies:
    1
    Views:
    760
  2. Replies:
    3
    Views:
    878
  3. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    3
    Views:
    391
    =?Utf-8?B?ZGF2aWQ=?=
    Oct 20, 2006
  4. Kel
    Replies:
    0
    Views:
    369
  5. SethM
    Replies:
    6
    Views:
    138
    Bob Barrows [MVP]
    Sep 22, 2008
Loading...

Share This Page