I get syntax error when i try to run and insert data in my database.... i have a log in button and delete button that works just fine.... but this one does not and i don't get it..... Can some one tell me an alternative to insert or what is the mistake?
public partial class Register : Form
{
private OleDbConnection connect = new OleDbConnection();
public Register()
{
InitializeComponent();
connect.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=resources\Users.accdb;
Persist Security Info=False;";
}
private void register1_Click(object sender, EventArgs e)
{
try
{
connect.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connect;
command.CommandText ="insert into Users(Username, Password, Email) values(' " + userR_box.Text + " ',' " + passwordR_box.Text + " ',' " + mailR_box.Text + " ')";
if ((userR_box.Text == "") || (passwordR_box.Text == "") || (mailR_box.Text == ""))
{
MessageBox.Show("Va rugam completati toate campurile");
}
else
{
command.ExecuteNonQuery();
}
}
catch (Exception ex)
{
MessageBox.Show("Error "+ ex);
}
connect.Close();
}