Create a Sql Select Command Parameterized...

By Goniey N (Mr. G)

Show How To Create a Sql Select Command Parameterized...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True")
Dim cmd As New SqlCommand
        cmd.CommandType = CommandType.Text
        cmd.CommandText = "SELECT StudentIdID, StudentName FROM Students WHERE StudentName LIKE @studName"
        cmd.
Connection = con
        
Dim StudentNameParameter As New SqlParameter("@studName", "g%")
        cmd.
Parameters.Add(StudentNameParameter)
End Sub

Create a Sql Select Command Parameterized...  (781 Views)