here is an input code i wrote to input data from the user interface to database in access. error occured when i tried to run the problem. the error messages are as follow.
1. ObjCmd is not declared
2. SqlCommand is not defined.
the code is as shown below (is written with vb.net). the name of the file in the access is chiscoTransport and the name of the table is seatReservation
please help me debug the errors
[CODE=vbnet]Private Sub submitButton_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles submitButton.Cl ick
Dim Objconn As New SqlClient.SqlCo nnection("Data Source=.\SQLEXP RESS;AttachDbFi lename=|DataDir ectory|\chiscoT ransport.mdb;In tegrated Security=True;C onnect Timeout=30;User Instance=True")
Objconn.Open()
ObjCmd = New SqlCommand("INS ERT INTO seatReservation (vehicleID, pname, deptureT, trvllingft, pssngerAD, phoneNo, fare, time, exptdjd, date) VALUES (@vehicleID, @pname, @deptureT, @trvllingft, @pssngerAD, @phoneNo, @fare, @time, @exptdjd, @date)", Objconn)
ObjCmd.Paramete rs.Add("@vehicl eID", Data.SqlDbType. VarChar).Value = vehicleIDComboB ox.Text
ObjCmd.Paramete rs.Add("@pname" , Data.SqlDbType. Text).Value = pnameTextBox.Te xt
ObjCmd.Paramete rs.Add("@deptur eT", Data.SqlDbType. Text).Value = deptureTComboBo x.Text
ObjCmd.Paramete rs.Add("@trvlli ngft", Data.SqlDbType. Text).Value = trvllingftCombo Box.Text
ObjCmd.Paramete rs.Add("@pssnge rAD", Data.SqlDbType. Text).Value = pssngerADTextBo x.Text
ObjCmd.Paramete rs.Add("@phoneN o", Data.SqlDbType. Int).Value = phoneNoTextBox. Text
ObjCmd.Paramete rs.Add("@fare", Data.SqlDbType. Int).Value = fareTextBox.Tex t
ObjCmd.Paramete rs.Add("@time", Data.SqlDbType. Text).Value = timeTextBox.Tex t
ObjCmd.Paramete rs.Add("@exptdj d", Data.SqlDbType. Text).Value = exptdjdTextBox. Text
ObjCmd.Paramete rs.Add("@date", Data.SqlDbType. Text).Value = dateTextBox.Tex t
Objbtn.ExecuteN onQuery()
Objconn.Close()
End Sub[/CODE]
1. ObjCmd is not declared
2. SqlCommand is not defined.
the code is as shown below (is written with vb.net). the name of the file in the access is chiscoTransport and the name of the table is seatReservation
please help me debug the errors
[CODE=vbnet]Private Sub submitButton_Cl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles submitButton.Cl ick
Dim Objconn As New SqlClient.SqlCo nnection("Data Source=.\SQLEXP RESS;AttachDbFi lename=|DataDir ectory|\chiscoT ransport.mdb;In tegrated Security=True;C onnect Timeout=30;User Instance=True")
Objconn.Open()
ObjCmd = New SqlCommand("INS ERT INTO seatReservation (vehicleID, pname, deptureT, trvllingft, pssngerAD, phoneNo, fare, time, exptdjd, date) VALUES (@vehicleID, @pname, @deptureT, @trvllingft, @pssngerAD, @phoneNo, @fare, @time, @exptdjd, @date)", Objconn)
ObjCmd.Paramete rs.Add("@vehicl eID", Data.SqlDbType. VarChar).Value = vehicleIDComboB ox.Text
ObjCmd.Paramete rs.Add("@pname" , Data.SqlDbType. Text).Value = pnameTextBox.Te xt
ObjCmd.Paramete rs.Add("@deptur eT", Data.SqlDbType. Text).Value = deptureTComboBo x.Text
ObjCmd.Paramete rs.Add("@trvlli ngft", Data.SqlDbType. Text).Value = trvllingftCombo Box.Text
ObjCmd.Paramete rs.Add("@pssnge rAD", Data.SqlDbType. Text).Value = pssngerADTextBo x.Text
ObjCmd.Paramete rs.Add("@phoneN o", Data.SqlDbType. Int).Value = phoneNoTextBox. Text
ObjCmd.Paramete rs.Add("@fare", Data.SqlDbType. Int).Value = fareTextBox.Tex t
ObjCmd.Paramete rs.Add("@time", Data.SqlDbType. Text).Value = timeTextBox.Tex t
ObjCmd.Paramete rs.Add("@exptdj d", Data.SqlDbType. Text).Value = exptdjdTextBox. Text
ObjCmd.Paramete rs.Add("@date", Data.SqlDbType. Text).Value = dateTextBox.Tex t
Objbtn.ExecuteN onQuery()
Objconn.Close()
End Sub[/CODE]
Comment