G
Guest
Hi.
This is killing me. I am trying to insert a row into an Access table, but
it's giving me an exception as below.
"Syntax error in INSERT INTO statement."
When I debug and look at the SQL string it is as follows.
"insert into tblCustomer (PropertyType, FirstName, LastName, Address1,
Address2, City, State, Zip, HomePhone, DaytimePhone, MobilePhone, OtherPhone,
Email, Password) values (0, 'Jay', 'Park', '41103 Oakriver Lane', '', 'Las
Vegas', 'CA', '91321', '', '333', '', '', 'Email', 'Password')"
If I copy the above statement in SQL View, it is fine. I just don't get it.
The below is my code.
private int InsertCustomer(OleDbConnection oConn)
{
string sSQL = "insert into tblCustomer (PropertyType, FirstName,
LastName, Address1, Address2, City, State, Zip, HomePhone, DaytimePhone,
MobilePhone, OtherPhone, Email, Password) values (" +
Session["PropertyType"].ToString() + ", '" + Session["FirstName"] + "', '" +
Session["LastName"] + "', '" + Session["Address1"] + "', '" +
Session["Address2"] + "', '" + Session["City"] + "', '" + Session["State"] +
"', '" + Session["ZipCode"] + "', '" + Session["HomePhone"] + "', '" +
Session["DaytimePhone"] + "', '" + Session["MobilePhone"] + "', '" +
Session["OtherPhone"] + "', '" + Session["Email"] + "', '" +
Session["Password"] + "')";
OleDbCommand oCmd = new OleDbCommand(sSQL, oConn);
oCmd.ExecuteNonQuery();
Your input is appreciated.
J
This is killing me. I am trying to insert a row into an Access table, but
it's giving me an exception as below.
"Syntax error in INSERT INTO statement."
When I debug and look at the SQL string it is as follows.
"insert into tblCustomer (PropertyType, FirstName, LastName, Address1,
Address2, City, State, Zip, HomePhone, DaytimePhone, MobilePhone, OtherPhone,
Email, Password) values (0, 'Jay', 'Park', '41103 Oakriver Lane', '', 'Las
Vegas', 'CA', '91321', '', '333', '', '', 'Email', 'Password')"
If I copy the above statement in SQL View, it is fine. I just don't get it.
The below is my code.
private int InsertCustomer(OleDbConnection oConn)
{
string sSQL = "insert into tblCustomer (PropertyType, FirstName,
LastName, Address1, Address2, City, State, Zip, HomePhone, DaytimePhone,
MobilePhone, OtherPhone, Email, Password) values (" +
Session["PropertyType"].ToString() + ", '" + Session["FirstName"] + "', '" +
Session["LastName"] + "', '" + Session["Address1"] + "', '" +
Session["Address2"] + "', '" + Session["City"] + "', '" + Session["State"] +
"', '" + Session["ZipCode"] + "', '" + Session["HomePhone"] + "', '" +
Session["DaytimePhone"] + "', '" + Session["MobilePhone"] + "', '" +
Session["OtherPhone"] + "', '" + Session["Email"] + "', '" +
Session["Password"] + "')";
OleDbCommand oCmd = new OleDbCommand(sSQL, oConn);
oCmd.ExecuteNonQuery();
Your input is appreciated.
J