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. Change Query Type To Check Query Before Executing [modified]

Change Query Type To Check Query Before Executing [modified]

Scheduled Pinned Locked Moved Database
databasequestionannouncement
8 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.
  • K Offline
    K Offline
    Kyudos
    wrote on last edited by
    #1

    As an advanced option in my DB GUI I have included the ability to run SQL queries on the DB (an Access MDB). Before running DELETE or UPDATE queries, I'd like to be able to convert them to SELECT queries so that I can issues a message like "This will DELETE/UPDATE 18 records, are you sure?" Does anyone know of any code to do this? I can't believe I'm the only person to want to do it, but Google is failing me. (I know I could probably do this by automating Access, which has 'change query type' functions, but the whole reason for my GUI is that my users might not have Access) Cheers

    modified on Wednesday, September 29, 2010 8:55 PM

    D M 2 Replies Last reply
    0
    • K Kyudos

      As an advanced option in my DB GUI I have included the ability to run SQL queries on the DB (an Access MDB). Before running DELETE or UPDATE queries, I'd like to be able to convert them to SELECT queries so that I can issues a message like "This will DELETE/UPDATE 18 records, are you sure?" Does anyone know of any code to do this? I can't believe I'm the only person to want to do it, but Google is failing me. (I know I could probably do this by automating Access, which has 'change query type' functions, but the whole reason for my GUI is that my users might not have Access) Cheers

      modified on Wednesday, September 29, 2010 8:55 PM

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      What about wraping the query execution in a transaction, where you would get the number of rows affected, then prompt the user with "Are you sure ?". If the user answers, Yes, then commit the transaction else rollback the transaction. This assumes that you can do transactions in MS-Access .... I'm not sure. Good Luck. :thumbsup:

      K 1 Reply Last reply
      0
      • K Kyudos

        As an advanced option in my DB GUI I have included the ability to run SQL queries on the DB (an Access MDB). Before running DELETE or UPDATE queries, I'd like to be able to convert them to SELECT queries so that I can issues a message like "This will DELETE/UPDATE 18 records, are you sure?" Does anyone know of any code to do this? I can't believe I'm the only person to want to do it, but Google is failing me. (I know I could probably do this by automating Access, which has 'change query type' functions, but the whole reason for my GUI is that my users might not have Access) Cheers

        modified on Wednesday, September 29, 2010 8:55 PM

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        I'm not sure how you handle queries in Access spit but I would replace DELETE with Select Count(*) and execute the select query, use the results to hassle the user and then delete the data. BTW I cannot imagine giving a user the ability to write and execute sql code against the database, advanced or not. The mere fact that you want to get confirmation from your user supports my horror.

        Never underestimate the power of human stupidity RAH

        K 1 Reply Last reply
        0
        • D David Mujica

          What about wraping the query execution in a transaction, where you would get the number of rows affected, then prompt the user with "Are you sure ?". If the user answers, Yes, then commit the transaction else rollback the transaction. This assumes that you can do transactions in MS-Access .... I'm not sure. Good Luck. :thumbsup:

          K Offline
          K Offline
          Kyudos
          wrote on last edited by
          #4

          David - this approach works fine, thanks a lot!

          1 Reply Last reply
          0
          • M Mycroft Holmes

            I'm not sure how you handle queries in Access spit but I would replace DELETE with Select Count(*) and execute the select query, use the results to hassle the user and then delete the data. BTW I cannot imagine giving a user the ability to write and execute sql code against the database, advanced or not. The mere fact that you want to get confirmation from your user supports my horror.

            Never underestimate the power of human stupidity RAH

            K Offline
            K Offline
            Kyudos
            wrote on last edited by
            #5

            I know what you mean about user access to SQL - but the support benefits of having this are considerable (not least because it means I don't have to write GUI code for every table blah blah). Still, it'll probably end up hidden behind a secret key combination know only to the enlightened few. Or something like that!

            D 1 Reply Last reply
            0
            • K Kyudos

              I know what you mean about user access to SQL - but the support benefits of having this are considerable (not least because it means I don't have to write GUI code for every table blah blah). Still, it'll probably end up hidden behind a secret key combination know only to the enlightened few. Or something like that!

              D Offline
              D Offline
              David Mujica
              wrote on last edited by
              #6

              Do yourself a favor and create a CYA (cover your ass) log table which would capture the SQL statement, User, DateTimeStamp. This will also come in handy when you get the call, "The data was there on Friday !" Also, take frequent backups.

              L K 2 Replies Last reply
              0
              • D David Mujica

                Do yourself a favor and create a CYA (cover your ass) log table which would capture the SQL statement, User, DateTimeStamp. This will also come in handy when you get the call, "The data was there on Friday !" Also, take frequent backups.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                David Mujica wrote:

                a CYA (cover your ass) log table

                +5, but wouldn't you rather have a lightweight trace that keeps track of this stuff?

                David Mujica wrote:

                Also, take frequent backups

                :thumbsup: --edit Aw, Microsoft Access, not Sql Server! Forget the trace :)

                I are Troll :suss:

                modified on Thursday, September 30, 2010 1:03 PM

                1 Reply Last reply
                0
                • D David Mujica

                  Do yourself a favor and create a CYA (cover your ass) log table which would capture the SQL statement, User, DateTimeStamp. This will also come in handy when you get the call, "The data was there on Friday !" Also, take frequent backups.

                  K Offline
                  K Offline
                  Kyudos
                  wrote on last edited by
                  #8

                  Logging is probably a good idea. My GUI already makes automatic backups :rolleyes:

                  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