con.Open()
Dim [COLOR="#008000"]cmd[/COLOR] As [B][U]New SqlCommand[/U][/B]
[COLOR="#008000"]cmd[/COLOR].Connection = con
Try
[COLOR="#008000"]cmd[/COLOR].CommandText = "INSERT INTO Professor(IDNo,LastName,FirstName,MiddleName,Department)VALUES(@IDNo,@LastName,@FirstName,@MiddleName,@Department)"
Dim [COLOR="#FF0000"]inscmd[/COLOR] As [B][U]New SqlCommand[/U][/B]
[COLOR="#FF0000"]inscmd[/COLOR].Parameters.AddWithValue("@IDNo", txtsearch.Text)
[COLOR="#FF0000"]inscmd[/COLOR].Parameters.AddWithValue("@LastName", txtln.Text)
[COLOR="#FF0000"]inscmd[/COLOR].Parameters.AddWithValue("@FirstName", txtfn.Text)
[COLOR="#FF0000"]inscmd[/COLOR].Parameters.AddWithValue("@MiddleName", txtmn.Text)
[COLOR="#FF0000"]inscmd[/COLOR].Parameters.AddWithValue("@Department", txtdep.Text)
[COLOR="#008000"]cmd[/COLOR].ExecuteNonQuery()
MessageBox.Show("NEW ACCOUNT HAS BEED ADDED TO YOUR DATABASE!")
Catch ex As Exception
MessageBox.Show("YOUR ACCOUNT COULD NOT BE ADDED! " & ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub