-
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
-
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).