Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error inserting records into MySql table using Asp 2.0 [modified]

Error inserting records into MySql table using Asp 2.0 [modified]

Scheduled Pinned Locked Moved ASP.NET
databasehelpcsharpasp-netmysql
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mlingamus
    wrote on last edited by
    #1

    I created a form view in asp.net for a data entry web page. User inputs data which is supposed to get inserted into my MySql database in a existing database. but when I try the following code, I get the following error: System.Data.Odbc.OdbcException: ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.45-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'product_id, 'Button Up'product_name, 'shirts'product_desc, 1000tot_qty, 36tot_ca' at line 2 This is the script I am running in my .aspx file. InsertCommand="insert into product(product_id, product_name, product_desc, tot_qty, tot_cartons, cost, tot_colors,qty_per_carton, arrival_date, custom_clearedby, ship_mode) values( ?product_id, ?product_name, ?product_desc, ?tot_qty, ?tot_cartons, ?cost, ?tot_colors,?qty_per_carton, ?arrival_date, ?custom_clearedby, ?ship_mode); I would really appreciate any help/insight. Thanks in advance

    modified on Monday, May 19, 2008 12:17 PM

    D 1 Reply Last reply
    0
    • M mlingamus

      I created a form view in asp.net for a data entry web page. User inputs data which is supposed to get inserted into my MySql database in a existing database. but when I try the following code, I get the following error: System.Data.Odbc.OdbcException: ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.45-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'product_id, 'Button Up'product_name, 'shirts'product_desc, 1000tot_qty, 36tot_ca' at line 2 This is the script I am running in my .aspx file. InsertCommand="insert into product(product_id, product_name, product_desc, tot_qty, tot_cartons, cost, tot_colors,qty_per_carton, arrival_date, custom_clearedby, ship_mode) values( ?product_id, ?product_name, ?product_desc, ?tot_qty, ?tot_cartons, ?cost, ?tot_colors,?qty_per_carton, ?arrival_date, ?custom_clearedby, ?ship_mode); I would really appreciate any help/insight. Thanks in advance

      modified on Monday, May 19, 2008 12:17 PM

      D Offline
      D Offline
      doWhileSomething
      wrote on last edited by
      #2

      When trouble shooting commands like this, it always helps to show all of the relevant code (e.g. paramaters). Each paramater "?some_param" should be assigned a value, you did not post this part of the code. Also, the paramaters should be added in the same order they are used in you MySql statement. I also don't see you closing the string, however this might be a copy/paste typo. Nonetheless, complete code is essential especially when this appears to be some type of string problem. Based on your posted example, they should look like this: mysqlCmd.Parameters.AddWithValue("?product_id", "some_value") mysqlCmd.Parameters.AddWithValue("?product_name", "some_value") mysqlCmd.Parameters.AddWithValue("?product_desc", "some_value") etc.. Hope this helps!

      My Personal Site

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups