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. Database & SysAdmin
  3. Database
  4. What is wrong with these SQL statements??

What is wrong with these SQL statements??

Scheduled Pinned Locked Moved Database
databasequestionhelp
7 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.
  • I Offline
    I Offline
    IrishSonic
    wrote on last edited by
    #1

    Hiya getting a message saying "Database error - There were no columns specified to retrive." when using these 2 lines: SqlString = "DELETE * from Branches WHERE Branch_No LIKE '4%' "; OR SqlString = "INSERT INTO Branches (Branch_No,Branch_Name) VALUES ('6','Derry') "; But Branch_No is the first column and Branch_Name is the second.. Am I using the statements wrong?? Thanks, grahamoj.

    M 1 Reply Last reply
    0
    • I IrishSonic

      Hiya getting a message saying "Database error - There were no columns specified to retrive." when using these 2 lines: SqlString = "DELETE * from Branches WHERE Branch_No LIKE '4%' "; OR SqlString = "INSERT INTO Branches (Branch_No,Branch_Name) VALUES ('6','Derry') "; But Branch_No is the first column and Branch_Name is the second.. Am I using the statements wrong?? Thanks, grahamoj.

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      DELETE statement do not need * from.Change it to: DELETE Branches WHERE Branch_No LIKE '4%' For second one,Whats the type of columns? Mazy "And the carpet needs a haircut, and the spotlight looks like a prison break And the telephone's out of cigarettes, and the balcony is on the make And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits

      K 1 Reply Last reply
      0
      • M Mazdak

        DELETE statement do not need * from.Change it to: DELETE Branches WHERE Branch_No LIKE '4%' For second one,Whats the type of columns? Mazy "And the carpet needs a haircut, and the spotlight looks like a prison break And the telephone's out of cigarettes, and the balcony is on the make And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits

        K Offline
        K Offline
        karl_w
        wrote on last edited by
        #3

        You don't need the "*" but you'll need "from" so the right statement will be (at least in SQL92) DELETE FROM branches WHERE branch_no LIKE '4%' -- karl

        M 1 Reply Last reply
        0
        • K karl_w

          You don't need the "*" but you'll need "from" so the right statement will be (at least in SQL92) DELETE FROM branches WHERE branch_no LIKE '4%' -- karl

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #4

          Yes. :) Mazy "And the carpet needs a haircut, and the spotlight looks like a prison break And the telephone's out of cigarettes, and the balcony is on the make And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits

          I 1 Reply Last reply
          0
          • M Mazdak

            Yes. :) Mazy "And the carpet needs a haircut, and the spotlight looks like a prison break And the telephone's out of cigarettes, and the balcony is on the make And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits

            I Offline
            I Offline
            IrishSonic
            wrote on last edited by
            #5

            Would you have a full list of all the statements( that is right syntax ) available to use for me?? What is the syntax for the INSERT?? Thanks for ur help. grahamoj.

            I 1 Reply Last reply
            0
            • I IrishSonic

              Would you have a full list of all the statements( that is right syntax ) available to use for me?? What is the syntax for the INSERT?? Thanks for ur help. grahamoj.

              I Offline
              I Offline
              IrishSonic
              wrote on last edited by
              #6

              Hiya have tried the DELETE as u suggested but still not working for me. I think I know what it is though. What should this line change to for reading and writing.. // Execute the query recset.Open( CRecordset::forwardOnly,SqlString,CRecordset::readOnly ); Have tried a "CRecordset::writeOnly, but none exists. Thanks grahamoj. Have also tried this: recset.Open( AFX_DB_USE_DEFAULT_TYPE,SqlString,CRecordset::none );

              K 1 Reply Last reply
              0
              • I IrishSonic

                Hiya have tried the DELETE as u suggested but still not working for me. I think I know what it is though. What should this line change to for reading and writing.. // Execute the query recset.Open( CRecordset::forwardOnly,SqlString,CRecordset::readOnly ); Have tried a "CRecordset::writeOnly, but none exists. Thanks grahamoj. Have also tried this: recset.Open( AFX_DB_USE_DEFAULT_TYPE,SqlString,CRecordset::none );

                K Offline
                K Offline
                karl_w
                wrote on last edited by
                #7

                Could you post your table-definition? What database are you using? Maybe you have to use \' instead of ' ? A full SQL-Specification can be found here: http://developer.mimer.com/documentation/Mimer_SQL_Reference_Manual/Mimer_SQL_ReferenceTOC.html[^] -- karl

                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