Hi i have written my code to to insert data that has been entered into my textboxes n my form into my access database.
i am gettin an error message saying: OLEDBEXEPTION OCCURED...Syntax error in INSERT INTO statement.
i was wondering if someone could look over my code and tell me where im going wrong
the code is written for when the button on the form is pressed.
my code is...
OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand OleDbConnection1 = New System.Data.OleDb.OleDbConnection OleDbInsertCommand1.CommandText = "INSERT INTO Admin,(Employee_Forename, Employee_Surname, Admin_Username, Admin_Password) VALUES (Employee_ForenameTextBox.Text, Employee_SurnameTextBox.Text, Admin_UsernameTextBox.Text, Admin_PasswordTextBox.Text)" OleDbInsertCommand1.Connection = Me.OleDbConnection1 OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\mydatabase.mdb" Try OleDbConnection1.Open() OleDbInsertCommand1.ExecuteNonQuery() Catch ex As OleDb.OleDbException MessageBox.Show(ex.ToString) End Try OleDbConnection1.Close()
Edited 6 Years Ago by student21: n/a