Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 2nd, 2006, 01:13 PM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default NEED HELP INSERT INTO statement syntax error

 Please I need help with this error. I dont know what to do



SQL statement:

string reg;
         reg = "INSERT INTO Customer(Name, Surname,User, Pass, Address1, Email1)";
         reg += " VALUE('" +first.Text+ "','" +second.Text+ "','" +user.Text+ "','" +pass.Text+ "','" +address1.Text+ "','" +email.Text+ "');";









Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

Source Error:

Line 35:
Line 36: connection.Open();
Line 37: command.ExecuteNonQuery();
Line 38:
Line 39: Response.Redirect("product.aspx");


Source File: c:\Application development website\links\register.aspx Line: 37

Stack Trace:

[OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) +177
   System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) +194
   System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) +56
   System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) +105
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +89
   ASP.register_aspx.register_click(Object sender, EventArgs e) in c:\Application development website\links\register.aspx:37
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
   System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +97
   System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919



 
Old June 2nd, 2006, 01:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

shouldn't be VALUES instead of VALUE????

HTH

Gonzalo
 
Old June 2nd, 2006, 02:15 PM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried this again I am getting the same error. Other suggestion???

 
Old June 2nd, 2006, 02:22 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

It has to be VALUES. There is some other error there. I wouldn't use the + . Use & instead. Debug and post your SQL statement here.

 
Old June 2nd, 2006, 03:12 PM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much I finished it I completed. Do you want me to insert the complete code to see it??

 
Old June 2nd, 2006, 03:57 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Yes, I would appreciate know what the solution was.

Thank you.

 
Old June 2nd, 2006, 04:01 PM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Complete solution:


 public void register_click(object sender, EventArgs e)
     { //I have changed this part as defined in my report because there was no availability of using XML file in the Computer Suite

         OleDbConnection connection = new OleDbConnection();
         string dbconn;
         dbconn = "Provider=Microsoft.Jet.OLEDB.4.0;";
         dbconn += "Data Source= " + HttpContext.Current.Server.MapPath("accessMyWebsit e.mdb");
         connection.ConnectionString = dbconn;



         // insert data into registration table

         string reg;
         reg = "INSERT INTO Customer([Name], [Surname], [User], [Pass], [Address1], [Email1])";
         reg += " VALUES ('" +first.Text+ "','" +second.Text+ "','" +user.Text+ "','" +pass.Text+ "','" +address1.Text+ "','" +email.Text+ "');";

         //Define ADO.NET objects
         OleDbCommand command = new OleDbCommand();
         command.CommandText = reg;
         command.Connection = connection;

         connection.Open();

          command.ExecuteNonQuery();

         Response.Redirect("login.aspx");

         connection.Close();
     }

Thanks to all that contributed







Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax error in INSERT INTO statement mega ASP.NET 1.0 and 1.1 Basics 3 January 12th, 2005 04:30 PM
Syntax error in INSERT INTO statement. askaggs Classic ASP Databases 5 June 10th, 2004 12:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.