lim

lim

  • NA
  • 16
  • 0

Syntax Error in INSERT INTO statement

Jan 24 2006 8:29 PM
Dear All,

I am encountering syntax error in INSERT INTO statement when I run the following code.

String myConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +

@"Data source= C:\\123\\Login.mdb";

String myAddQuery = @"INSERT INTO UserLogin " +

@"(Name, EmpID, Dept, UserID, Password) " +

"VALUES (\'" + Name + "\',\'" +

EmpID + "\',\'" +

Dept + "\',\'" +

UserID + "\',\'" +

Password + "\')";

MessageBox.Show(myAddQuery);

try

{

OleDbConnection conn = new OleDbConnection(myConnectionString);

OleDbCommand myCommand = new OleDbCommand(myAddQuery, conn);

conn.Open();

rv = myCommand.ExecuteNonQuery();

}

catch (OleDbException e)

{

MessageBox.Show("OleDB Error: " + e.Message);

}

finally

{

// if (conn

}

}

}

Can anyone please help? I am using Access Database.

Thanks


Answers (2)