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. INSERT INTO and SELECT statements... pls help urgently

INSERT INTO and SELECT statements... pls help urgently

Scheduled Pinned Locked Moved ASP.NET
helpquestiondatabase
3 Posts 3 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.
  • F Offline
    F Offline
    For_IT
    wrote on last edited by
    #1

    Hi I am developing a UserControl, I save this user control code to the database, which will be loaded dynamically to the Page. In my user control code consist of following lines: At this moment, I am manually puting this data to data base using "INSERT INTO" statement. But I get following error: Incorrect syntax near 'ProductID'. This is because single quotation mark around ProductID (field_product_id='ProductID'). If I change this single quotation to double quotation (e.g. field_id="ProductID") then this works okay. But in that scenario, SELECT statement fails while execution. Can anyone please let me know how can I achieve both successfully? Thanks in advance.

    P M 2 Replies Last reply
    0
    • F For_IT

      Hi I am developing a UserControl, I save this user control code to the database, which will be loaded dynamically to the Page. In my user control code consist of following lines: At this moment, I am manually puting this data to data base using "INSERT INTO" statement. But I get following error: Incorrect syntax near 'ProductID'. This is because single quotation mark around ProductID (field_product_id='ProductID'). If I change this single quotation to double quotation (e.g. field_id="ProductID") then this works okay. But in that scenario, SELECT statement fails while execution. Can anyone please let me know how can I achieve both successfully? Thanks in advance.

      P Offline
      P Offline
      postmaster programmingknowledge com
      wrote on last edited by
      #2

      How about SelectCommand="SELECT field_defaultvalue FROM cp_productfields WHERE field_product_id=" & ProductID & " AND field_type=" & DropDownList & " AND field_Control_ID=" & ddVCAuflag Thank you http://www.programmingknowledge.com/[^]

      1 Reply Last reply
      0
      • F For_IT

        Hi I am developing a UserControl, I save this user control code to the database, which will be loaded dynamically to the Page. In my user control code consist of following lines: At this moment, I am manually puting this data to data base using "INSERT INTO" statement. But I get following error: Incorrect syntax near 'ProductID'. This is because single quotation mark around ProductID (field_product_id='ProductID'). If I change this single quotation to double quotation (e.g. field_id="ProductID") then this works okay. But in that scenario, SELECT statement fails while execution. Can anyone please let me know how can I achieve both successfully? Thanks in advance.

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #3

        You can avoid this issue if you use the parameterised queries when you execute the SQL commands.

        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