dcsimg
Results 1 to 2 of 2

Thread: How to use this code with a stored preocedure instead of text query?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Question How to use this code with a stored preocedure instead of text query?

    I would like to change this code to call a stored procedure. Can someone show me what to change to make this happen? I left out the connection string but have that already.

    Thanks!

    Code:
                Dim conn As New SqlConnection()
                conn.ConnectionString = ConnString7
                Dim selectQuery1 As String = "SELECT field1, field2, field3 FROM Courses WHERE (Share = 'A') OR (Share = 'G' AND GroupNo = '" & GroupNo2 & "' AND GroupNo <> '') OR (Share = 'P' AND ProviderNo = '" & ProviderNo2 & "')"
                Dim adapter1 As New SqlDataAdapter(selectQuery1, conn)
                Dim dt1 As New DataTable()
                conn.Open()
                adapter1.Fill(dt1)
                conn.Close()
                gvCourses.DataSource = dt1

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,150

    Re: How to use this code with a stored preocedure instead of text query?

    Code:
    Dim selectQuery1 As String = "StoredProcedureNameHere"
    Dim adapter1 As New SqlDataAdapter(selectQuery1, conn)
    
    adapter1.SelectCommand.CommandType = CommandType.StoredProcedure

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width