Results 1 to 2 of 2

Thread: exec a stored proc

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    exec a stored proc

    from form load how do you execute a stored procedure on a sql server?


    this is what i have so far.

    Code:
    Public Class Form1
        Inherits System.Windows.Forms.Form
        
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim myConnection2 As New SqlConnection("data source=AUS-REPORTING;initial catalog=Log;user id=user;password=password")
            Dim strStoredProc As String
    
            strStoredProc = "EXEC p_testing"
    
            Dim sqlCmd As New SqlClient.SqlCommand(strStoredProc, myConnection2)
    
            Try
                sqlCmd.ExecuteNonQuery()
            Catch
    
            End Try
        End Sub
    
    End Class

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Easiest thing to do would be to:

    open up your server explorer, find the stored procedure in the list, and drag it onto your form (when its in design mode).

    That will give you all the code you need. (and it will work too!)

    Then you can rewrite by hardcoding it (copy and paste).

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