Protected Sub Button1_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim surname As DataColumn
Dim otherNames As DataColumn
Dim connection As SqlConnection = New SqlConnection(" server=olaolu\S QLEXPRESS;datab ase=Department Database;integr ated security=true")
Try
Dim command As SqlCommand = New SqlCommand("INS ERT INTO Student info ([SurName], [OtherNames]) VALUES (@SurName, @OtherNames)", connection)
command.Paramet ers.Add(New SqlParameter("@ surname", surname.DataTyp e))
command.Paramet ers.Add(New SqlParameter("@ OtherNames", OtherNames.Data Type))
connection.Open ()
command.Execute NonQuery()
connection.Clos e()
Finally
If connection.Stat e = ConnectionState .Open Then
connection.Clos e()
End If
End Try
a null reference exception results pls edit these codes 4 me.thanks
Dim surname As DataColumn
Dim otherNames As DataColumn
Dim connection As SqlConnection = New SqlConnection(" server=olaolu\S QLEXPRESS;datab ase=Department Database;integr ated security=true")
Try
Dim command As SqlCommand = New SqlCommand("INS ERT INTO Student info ([SurName], [OtherNames]) VALUES (@SurName, @OtherNames)", connection)
command.Paramet ers.Add(New SqlParameter("@ surname", surname.DataTyp e))
command.Paramet ers.Add(New SqlParameter("@ OtherNames", OtherNames.Data Type))
connection.Open ()
command.Execute NonQuery()
connection.Clos e()
Finally
If connection.Stat e = ConnectionState .Open Then
connection.Clos e()
End If
End Try
a null reference exception results pls edit these codes 4 me.thanks