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. General Programming
  3. Visual Basic
  4. simple SQL statements

simple SQL statements

Scheduled Pinned Locked Moved Visual Basic
helpdatabasecsharpquestion
7 Posts 4 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.
  • J Offline
    J Offline
    jamesbronw
    wrote on last edited by
    #1

    Hey people, I am having a really strange issue regarding SQL statements in my VB.NET code. The insert statement i have is INSERT INTO alarms(hour) VALUES (7) Now when I run the insert statement in a query from ACCESS it works fine no errors does what it needs to do. Yet, when I try to run it from my programm it says " ERROR IN INSERT INTO STATEMENT". Does anyone have any advice? I could really use it. Thanks for any help :)

    A M D 3 Replies Last reply
    0
    • J jamesbronw

      Hey people, I am having a really strange issue regarding SQL statements in my VB.NET code. The insert statement i have is INSERT INTO alarms(hour) VALUES (7) Now when I run the insert statement in a query from ACCESS it works fine no errors does what it needs to do. Yet, when I try to run it from my programm it says " ERROR IN INSERT INTO STATEMENT". Does anyone have any advice? I could really use it. Thanks for any help :)

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      I'm not on my testbox or I would double check this for you, but try a space between the table name and the columns list: INSERT INTO alarms (hour) VALUES (7) I've found ADODB can be slightly stricter than Access.

      1 Reply Last reply
      0
      • J jamesbronw

        Hey people, I am having a really strange issue regarding SQL statements in my VB.NET code. The insert statement i have is INSERT INTO alarms(hour) VALUES (7) Now when I run the insert statement in a query from ACCESS it works fine no errors does what it needs to do. Yet, when I try to run it from my programm it says " ERROR IN INSERT INTO STATEMENT". Does anyone have any advice? I could really use it. Thanks for any help :)

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

        give the table name as following. let "abc" is a table then the qry will be "insert into [abc] values(........)":-D

        J 1 Reply Last reply
        0
        • M mm_chanakaya

          give the table name as following. let "abc" is a table then the qry will be "insert into [abc] values(........)":-D

          J Offline
          J Offline
          jamesbronw
          wrote on last edited by
          #4

          Well thanks for the ideas but none of the two worked :( anyone have any other ideas as what it may be thats giving me such a hard time?

          1 Reply Last reply
          0
          • J jamesbronw

            Hey people, I am having a really strange issue regarding SQL statements in my VB.NET code. The insert statement i have is INSERT INTO alarms(hour) VALUES (7) Now when I run the insert statement in a query from ACCESS it works fine no errors does what it needs to do. Yet, when I try to run it from my programm it says " ERROR IN INSERT INTO STATEMENT". Does anyone have any advice? I could really use it. Thanks for any help :)

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Based on the information that you've given, the correct statement is

            INSERT INTO alarms (hour) VALUES (7)

            This assumes your database has a table called "alarms" with a column called "hour" that accepts an integer value. Double check the design of your database table to verify this. Also, we haven't seen your VB.NET code that your running around this statement. What sets it up and executes it? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            M 1 Reply Last reply
            0
            • D Dave Kreskowiak

              Based on the information that you've given, the correct statement is

              INSERT INTO alarms (hour) VALUES (7)

              This assumes your database has a table called "alarms" with a column called "hour" that accepts an integer value. Double check the design of your database table to verify this. Also, we haven't seen your VB.NET code that your running around this statement. What sets it up and executes it? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              M Offline
              M Offline
              mm_chanakaya
              wrote on last edited by
              #6

              no that is not that way let abc is a table with coloum x,y,z then the statment where x is varchar or char y is a number and z is date will be "insert into [abc](x,y,z)values("' value of x "'," value of y ","' value of z '")" if u r using some control to input the values then use "insert into [abc](x,y,z)values('" & controlnameX.text & "'," & controalnameY.text & ",'" & controlname.textZ & "')"

              D 1 Reply Last reply
              0
              • M mm_chanakaya

                no that is not that way let abc is a table with coloum x,y,z then the statment where x is varchar or char y is a number and z is date will be "insert into [abc](x,y,z)values("' value of x "'," value of y ","' value of z '")" if u r using some control to input the values then use "insert into [abc](x,y,z)values('" & controlnameX.text & "'," & controalnameY.text & ",'" & controlname.textZ & "')"

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                :wtf::omg::wtf::omg::wtf::omg::wtf::omg::wtf::omg::wtf::omg::wtf::wtf::wtf::omg::wtf: And this mean what to me? I'm not the one with the problem, and I'm probably one of the last people on this earth you should be preaching this crap to. I know how to build SQL procedures and how to integrate SQL with VB code. The person who originally posted the question has not given us enough information to give him a definitive answer to his problem. I told him to go back and double check the definition of the table against the SQL he's using as well as the BTW: I never use string concatentation to build SQL statements. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                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