Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 2nd, 2006, 02:13 PM
Authorized User
 
Join Date: Dec 2005
Location: , , Yugoslavia.
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



  #2 (permalink)  
Old June 2nd, 2006, 02:17 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
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
  #3 (permalink)  
Old June 2nd, 2006, 03:15 PM
Authorized User
 
Join Date: Dec 2005
Location: , , Yugoslavia.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

  #4 (permalink)  
Old June 2nd, 2006, 03:22 PM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
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.

  #5 (permalink)  
Old June 2nd, 2006, 04:12 PM
Authorized User
 
Join Date: Dec 2005
Location: , , Yugoslavia.
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??

  #6 (permalink)  
Old June 2nd, 2006, 04:57 PM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Yes, I would appreciate know what the solution was.

Thank you.

  #7 (permalink)  
Old June 2nd, 2006, 05:01 PM
Authorized User
 
Join Date: Dec 2005
Location: , , Yugoslavia.
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


 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 01:21 AM



All times are GMT -4. The time now is 04:57 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.