Results 1 to 2 of 2

Thread: Stored Procedures

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    14

    Stored Procedures

    am using the below code to execute a normal statement, but now want to turn it into a stored procedure. I ahve written the syored procedure 'sp_showTasks' and need to pass a parameter to it. How do I convert the below code to work with the SP??

    Dim nwindConn As SqlConnection = New SqlConnection(SQLCon)
    nwindConn.Open()
    Dim myCMD As SqlCommand = New SqlCommand("SELECT * FROM todo WHERE " & sqlStr & "", nwindConn)
    Dim todo As SqlDataReader = myCMD.ExecuteReader()

    Dim i = 0
    Do While todo.Read()

    loop
    ....................

    Cheers
    Tim

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I don't remember if the SQLCommand has a type property or not but you can just put the name of the SP where you have the SELECT statement:

    VB Code:
    1. Dim nwindConn As SqlConnection = New SqlConnection(SQLCon)
    2. nwindConn.Open()
    3. Dim myCMD As SqlCommand = New SqlCommand("sp_GetUserID", nwindConn)
    4. Dim todo As SqlDataReader = myCMD.ExecuteReader()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width