insert into error not recognized

  • Thread starter Antonio D'Ottavio
  • Start date
A

Antonio D'Ottavio

Good morning,
I've the following error
Syntax error in INSERT INTO statement
But I do not found any error in this code

OleDbconn = new OleDbConnection(sConnessioneDb);
string insertCmd = "insert into Organizzatori (NomeUtente, Password,
Nome, Cognome, IndirizzoPostaElettronica, Telefono) values ('eta' , 'eco' ,
'Antonioff' , 'ferfe' , '(e-mail address removed)' , '333333')";
OleDbCommand myCommand = new OleDbCommand(insertCmd, OleDbconn);
myCommand.Connection.Open();
try
{
myCommand.ExecuteNonQuery();
}
catch (OleDbException ex)
{
lblMsg1.Text = ex.Message ;
}
myCommand.Connection.Close();



Can you help me to discover the problem, I'm using an Access DB.

Many thanks

Antonio D'Ottavio
 
J

James Jenkins

Antonio D'Ottavio said:
Good morning,
I've the following error
Syntax error in INSERT INTO statement
But I do not found any error in this code

OleDbconn = new OleDbConnection(sConnessioneDb);
string insertCmd = "insert into Organizzatori (NomeUtente, Password,
Nome, Cognome, IndirizzoPostaElettronica, Telefono) values ('eta' , 'eco'
,
'Antonioff' , 'ferfe' , '(e-mail address removed)' , '333333')";
OleDbCommand myCommand = new OleDbCommand(insertCmd, OleDbconn);
myCommand.Connection.Open();
try
{
myCommand.ExecuteNonQuery();
}
catch (OleDbException ex)
{
lblMsg1.Text = ex.Message ;
}
myCommand.Connection.Close();



Can you help me to discover the problem, I'm using an Access DB.

Many thanks

Antonio D'Ottavio

Hi Antonio,
Have you checked the value types - e.g: is the '333333' a string or a long
value within database?
 
S

Siva M

I think 'password' is a reserved word in Jet. Try enclosing it in square
brackets ([]).

Good morning,
I've the following error
Syntax error in INSERT INTO statement
But I do not found any error in this code

OleDbconn = new OleDbConnection(sConnessioneDb);
string insertCmd = "insert into Organizzatori (NomeUtente, Password,
Nome, Cognome, IndirizzoPostaElettronica, Telefono) values ('eta' , 'eco' ,
'Antonioff' , 'ferfe' , '(e-mail address removed)' , '333333')";
OleDbCommand myCommand = new OleDbCommand(insertCmd, OleDbconn);
myCommand.Connection.Open();
try
{
myCommand.ExecuteNonQuery();
}
catch (OleDbException ex)
{
lblMsg1.Text = ex.Message ;
}
myCommand.Connection.Close();



Can you help me to discover the problem, I'm using an Access DB.

Many thanks

Antonio D'Ottavio
 
A

Antonio D'Ottavio

I've changed the password filed with a pwd file, but I've again the error
....
Thanks the same
 
A

Antonio D'Ottavio

The field phone is a string ... I think is it right in this way, hope so
 
R

Rick Lones

Antonio said:
Good morning,
I've the following error
Syntax error in INSERT INTO statement
But I do not found any error in this code

OleDbconn = new OleDbConnection(sConnessioneDb);
string insertCmd = "insert into Organizzatori (NomeUtente, Password,
Nome, Cognome, IndirizzoPostaElettronica, Telefono) values ('eta' , 'eco' ,
'Antonioff' , 'ferfe' , '(e-mail address removed)' , '333333')";
OleDbCommand myCommand = new OleDbCommand(insertCmd, OleDbconn);
myCommand.Connection.Open();
try
{
myCommand.ExecuteNonQuery();
}
catch (OleDbException ex)
{
lblMsg1.Text = ex.Message ;
}
myCommand.Connection.Close();



Can you help me to discover the problem, I'm using an Access DB.

Many thanks

Antonio D'Ottavio
Antonio,

Have you tried using the .Net debugger to simply pick up your insertCmd string
at the point you are ready to send it and pasting it exactly as built into the
Access SQL window? Does that work? If not, your problem is indeed with the
syntax, not a .Net problem at all.

HTH,
-rick-
 
W

William \(Bill\) Vaughn

You will be fighting with this block of code from now until the water's
pumped out of New Orleans if you don't convert it to a Parameter-based
Command. The Parameters handle the framing issues (some of which you have
not encountered yet) and other issues that you have seen.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Top