Napalm
08-11-2004, 21:13
OleDbConnection cn=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Programmi\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb;Persist Security Info=False");
cn.Open();
OleDbCommand cmd=cn.CreateCommand();
cmd.CommandText="INSERT INTO Utenti (username,password,Nome,Cognome) VALUES (@usr,@pwd,@uname,@lastname)";
cmd.Parameters.Add("@usr",TextBox1.Text);
cmd.Parameters.Add("@pwd",TextBox2.Text);
cmd.Parameters.Add("@name",TextBox3.Text);
cmd.Parameters.Add("@lastname",TextBox4.Text);
cmd.ExecuteNonQuery();
cn.Close();
Risultato:
Errore di sintassi nell'istruzione INSERT INTO
[OleDbException (0x80040e14): Errore di sintassi nell'istruzione INSERT INTO.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +122
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +67
DefaultNamespace.reg.ok(Object sender, EventArgs e) +278
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
Ho provato a fare la query direttamente in access e funziona, query di tipo select funzionano perfettamente.. query di modifica inserimento eliminazione no.. dove può stare il problema?
NapalM
cn.Open();
OleDbCommand cmd=cn.CreateCommand();
cmd.CommandText="INSERT INTO Utenti (username,password,Nome,Cognome) VALUES (@usr,@pwd,@uname,@lastname)";
cmd.Parameters.Add("@usr",TextBox1.Text);
cmd.Parameters.Add("@pwd",TextBox2.Text);
cmd.Parameters.Add("@name",TextBox3.Text);
cmd.Parameters.Add("@lastname",TextBox4.Text);
cmd.ExecuteNonQuery();
cn.Close();
Risultato:
Errore di sintassi nell'istruzione INSERT INTO
[OleDbException (0x80040e14): Errore di sintassi nell'istruzione INSERT INTO.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +122
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +65
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +67
DefaultNamespace.reg.ok(Object sender, EventArgs e) +278
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
Ho provato a fare la query direttamente in access e funziona, query di tipo select funzionano perfettamente.. query di modifica inserimento eliminazione no.. dove può stare il problema?
NapalM