I wrote the below code to input new data from name and address textbox of a form to microsoft access but there are alot of error. the name of the table in the access is Hotel and the the fields are HotelName and HotelAddress . Please can somebody help me and debug. i used vb.net
Code:
Private Sub submitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Objconn As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ECBInvoicing.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
Objconn.Open()
ObjCmd = New SqlCommand("INSERT INTO hotel (HotelName, HotelAddress) VALUES (@HotelName, @HotelAddress)", Objconn)
ObjCmd.Parameters.Add("@HotelName", Data.SqlDbType.VarChar).Value = txtHotelname.Text
ObjCmd.Parameters.Add("@HotelAddress", Data.SqlDbType.VarChar).Value = txtHotelAddress.Text
ObjCmd.ExecuteNonQuery()
Objconn.Close()
End Sub
Comment