Validate student id,username if already exist in database table . Using VB.Net 2012 and SQL database on windows10 system. Thanks for your help.this is my first post so thank you for your help guys.

 Private Sub InsertSutdent()
    SQL.AddParam("@stud_name", txtFirstname.Text)
    SQL.AddParam("@stud_lastname", txtlastname.Text)
    SQL.AddParam("@stud_id", txtStudentId.Text)
    SQL.AddParam("@stud_username", txtUsername.Text)
    SQL.AddParam("@stud_course", cbxCourse.Text)
    SQL.AddParam("@stud_password", txtpassword.Text)
    SQL.AddParam("@active", Status.Checked)

        SQL.ExecQuery("INSERT INTO Student (Stud_Firstname,Stud_Lastname,Stud_idnum,Stud_Password,Stud_Course,JoinDate,Stud_Username,Active) " & _
                    "VALUES (@stud_name,@stud_lastname,@stud_id,@stud_password,@stud_course,GETDATE(),@stud_username,@active);", True)

        If SQL.HasException(True) Then Exit Sub

        If SQL.DBDT.Rows.Count > 0 Then
            Dim r As DataRow = SQL.DBDT.Rows(0)

            regrow.Text = (r("LastID").ToString)

        End If
        indicator.Text = "Added!"

        LoadStudent()
End Sub

One way to do this is to attempt a SELECT on the desired record.
If it does not exist, you can perform the INSERT.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.