VB.NET - How To Use SQL Server Stored Procedure In Visual Basic.Net
In This VB.NET Tutorial We Will See How To Use SQL Stored Procedure To Insert Data Using Microsoft SQL DataBase And Visual Basic .NET Programming Language.
Project Source Code:
Imports System.Data.SqlClient
Public Class VBNET_Using_SQL_Stored_Procedures
Dim connection As New SqlConnection("Server= SAMSNG-PC; Database = TestDB; Integrated Security = true")
Private Sub BTN_ADD_Click(sender As Object, e As EventArgs) Handles BTN_ADD.Click
Dim params(1) As SqlParameter
params(0) = New SqlParameter("@username", SqlDbType.VarChar)
params(0).Value = TextBoxUserName.Text
params(1) = New SqlParameter("@pass", SqlDbType.VarChar)
params(1).Value = TextBoxPassword.Text
Dim command As New SqlCommand()
command.Connection = connection
command.CommandType = CommandType.StoredProcedure
command.CommandText = "SP_ADD"
command.Parameters.AddRange(params)
connection.Open()
command.ExecuteNonQuery()
connection.Close()
End Sub
End Class
///////////////OUTPUT: