Wednesday, March 28, 2007

CodeSnip: Calling a Stored Procedure from ASP.NET 2.0: ASP Alliance

Protected Sub Btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn1.Click
Dim sConnStr As String = {MyConnectionString} Dim cnBKTest As New SqlConnection(sConnStr) Dim cmdTest As New SqlCommand("Insert_Test", cnBKTest)
cmdTest.CommandType = Data.CommandType.StoredProcedure
cmdTest.Parameters.Add(New SqlParameter("@TestParam", Data.SqlDbType.VarChar, 10)) cmdTest.Parameters("@TestParam").Value = "Testing"
cnBKTest.Open() cmdTest.ExecuteNonQuery() cnBKTest.Close()
End Sub

No comments: