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. Unwanted recordset behaviour !!!

Unwanted recordset behaviour !!!

Scheduled Pinned Locked Moved Database
databasehelpquestionannouncement
12 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.
  • S Offline
    S Offline
    scorp_scorp
    wrote on last edited by
    #1

    Dear all, I have the following: set rs = db.openrecordset ("select fname, lname from employee") while not rs.EOF with rs .delete end with rs.movenext loop When the code is run, data is directly deleted from my actuall table??? i dont want this to happen, i want to initialize this recordset and refill it with another data. it is deleting the table records directly even without updating (.Update) !!! I need an empty recordset to work on. The only way (i know) to create a recordset is to create one from a given table through an SQL stat. I couldnt find a way to create an empty recordset from scratsh or a dummy recordset without a predefined data source. Help !!!!

    0 will always beats the 1.

    M C 2 Replies Last reply
    0
    • S scorp_scorp

      Dear all, I have the following: set rs = db.openrecordset ("select fname, lname from employee") while not rs.EOF with rs .delete end with rs.movenext loop When the code is run, data is directly deleted from my actuall table??? i dont want this to happen, i want to initialize this recordset and refill it with another data. it is deleting the table records directly even without updating (.Update) !!! I need an empty recordset to work on. The only way (i know) to create a recordset is to create one from a given table through an SQL stat. I couldnt find a way to create an empty recordset from scratsh or a dummy recordset without a predefined data source. Help !!!!

      0 will always beats the 1.

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

      Try select fname, lname from employee where 1=1 that should get you back an empty recordset. When deleting data you are changing the content of the collection and usually you start from the end and work forward. If you delete record[0] what is the current record you want to move next from?

      Never underestimate the power of human stupidity RAH

      S C 2 Replies Last reply
      0
      • M Mycroft Holmes

        Try select fname, lname from employee where 1=1 that should get you back an empty recordset. When deleting data you are changing the content of the collection and usually you start from the end and work forward. If you delete record[0] what is the current record you want to move next from?

        Never underestimate the power of human stupidity RAH

        S Offline
        S Offline
        scorp_scorp
        wrote on last edited by
        #3

        i will not movenext after deletion, but i will add new record.

        Mycroft Holmes wrote:

        select fname, lname from employee where 1=1

        is returning all records in the table.

        0 will always beats the 1.

        modified on Tuesday, February 8, 2011 5:54 AM

        M 1 Reply Last reply
        0
        • M Mycroft Holmes

          Try select fname, lname from employee where 1=1 that should get you back an empty recordset. When deleting data you are changing the content of the collection and usually you start from the end and work forward. If you delete record[0] what is the current record you want to move next from?

          Never underestimate the power of human stupidity RAH

          C Offline
          C Offline
          Chris Meech
          wrote on last edited by
          #4

          Mycroft Holmes wrote:

          where 1=1

          Since the condtion is true for all rows, won't all rows be returned in the set? :confused:

          Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

          M 1 Reply Last reply
          0
          • S scorp_scorp

            Dear all, I have the following: set rs = db.openrecordset ("select fname, lname from employee") while not rs.EOF with rs .delete end with rs.movenext loop When the code is run, data is directly deleted from my actuall table??? i dont want this to happen, i want to initialize this recordset and refill it with another data. it is deleting the table records directly even without updating (.Update) !!! I need an empty recordset to work on. The only way (i know) to create a recordset is to create one from a given table through an SQL stat. I couldnt find a way to create an empty recordset from scratsh or a dummy recordset without a predefined data source. Help !!!!

            0 will always beats the 1.

            C Offline
            C Offline
            Chris Meech
            wrote on last edited by
            #5

            Can you explain further what your purpose is for requiring an "empty recordset"? Your question comes across somewhat odd. You have code that will delete records from the recordset and you express surprise that data is deleted and that you don't intend for that to happen. If you don't want data to be deleted, why do you have a delete statement on the recordset? :)

            Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

            S 1 Reply Last reply
            0
            • C Chris Meech

              Mycroft Holmes wrote:

              where 1=1

              Since the condtion is true for all rows, won't all rows be returned in the set? :confused:

              Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

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

              My error it should be 1 = -1 or ID = -1

              Never underestimate the power of human stupidity RAH

              1 Reply Last reply
              0
              • S scorp_scorp

                i will not movenext after deletion, but i will add new record.

                Mycroft Holmes wrote:

                select fname, lname from employee where 1=1

                is returning all records in the table.

                0 will always beats the 1.

                modified on Tuesday, February 8, 2011 5:54 AM

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

                My error try 1 = -1

                Never underestimate the power of human stupidity RAH

                1 Reply Last reply
                0
                • C Chris Meech

                  Can you explain further what your purpose is for requiring an "empty recordset"? Your question comes across somewhat odd. You have code that will delete records from the recordset and you express surprise that data is deleted and that you don't intend for that to happen. If you don't want data to be deleted, why do you have a delete statement on the recordset? :)

                  Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

                  S Offline
                  S Offline
                  scorp_scorp
                  wrote on last edited by
                  #8

                  Sure.... The delete statement is just to empty the record set, Why is that? it is because it came from an sql statement or a certain data source, and since i need an empty one , so am deleting the records in it. My purpose is to pass a recordset to a report, but this recordset is a collection or records from different sources ,lets say two coloumns form an sql statement and another coloumn which i need to append and populate. which is in my case the salary coloumn . .append , didnt work . so my guess was to start from with a recordset from any sql source, and delete its rows (initializing) , then add my data. but deleting rows end up in deleting rows from my actual table the recordset came from :~ so i need to start with an empty recordset in order to fill it up and pass it to report.

                  0 will always beats the 1.

                  modified on Tuesday, February 8, 2011 10:56 PM

                  J 1 Reply Last reply
                  0
                  • S scorp_scorp

                    Sure.... The delete statement is just to empty the record set, Why is that? it is because it came from an sql statement or a certain data source, and since i need an empty one , so am deleting the records in it. My purpose is to pass a recordset to a report, but this recordset is a collection or records from different sources ,lets say two coloumns form an sql statement and another coloumn which i need to append and populate. which is in my case the salary coloumn . .append , didnt work . so my guess was to start from with a recordset from any sql source, and delete its rows (initializing) , then add my data. but deleting rows end up in deleting rows from my actual table the recordset came from :~ so i need to start with an empty recordset in order to fill it up and pass it to report.

                    0 will always beats the 1.

                    modified on Tuesday, February 8, 2011 10:56 PM

                    J Offline
                    J Offline
                    Jorgen Andersson
                    wrote on last edited by
                    #9

                    Assuming you're collecting data from several tables in ONE database. Use a union query[^] instead, to fill the record set with the required data.

                    List of common misconceptions

                    S 1 Reply Last reply
                    0
                    • J Jorgen Andersson

                      Assuming you're collecting data from several tables in ONE database. Use a union query[^] instead, to fill the record set with the required data.

                      List of common misconceptions

                      S Offline
                      S Offline
                      scorp_scorp
                      wrote on last edited by
                      #10

                      Thanks Andersson , but i think UNION is not the right solution here, since it envolve a lot of constraints :( , like number of coloumns of the two SQL stat. should be the same. Other wise i think it save alot of lines of code :)

                      0 will always beats the 1.

                      J 1 Reply Last reply
                      0
                      • S scorp_scorp

                        Thanks Andersson , but i think UNION is not the right solution here, since it envolve a lot of constraints :( , like number of coloumns of the two SQL stat. should be the same. Other wise i think it save alot of lines of code :)

                        0 will always beats the 1.

                        J Offline
                        J Offline
                        Jorgen Andersson
                        wrote on last edited by
                        #11

                        The queries that are unioned together needs to have the same number of columns of the same type with the same names in the same order, that's correct. But that could be easily fixed using alias and dummy columns.

                        select a,b,c
                        from tbl1
                        union
                        select x as a,y as b,null as c
                        from tbl2

                        List of common misconceptions

                        S 1 Reply Last reply
                        0
                        • J Jorgen Andersson

                          The queries that are unioned together needs to have the same number of columns of the same type with the same names in the same order, that's correct. But that could be easily fixed using alias and dummy columns.

                          select a,b,c
                          from tbl1
                          union
                          select x as a,y as b,null as c
                          from tbl2

                          List of common misconceptions

                          S Offline
                          S Offline
                          scorp_scorp
                          wrote on last edited by
                          #12

                          Now this does make sense .... nice work around It worked fine (even the result data is not that much comprehensive) but it do the job, and save some extra lines of code ... great man, thanks alot :thumbsup:

                          0 will always beats the 1.

                          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