If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Copying records from one database to another

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-04, 16:36
VB6Data VB6Data is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
Unhappy Copying records from one database to another

My code looks like this:
Dim db As Connection
Dim RS2 As Recordset

Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\SESCOgx80\Databasebk\GX_DATA.MDB;"

Set RS2 = New Recordset
RS2.CursorType = adOpenKeyset
RS2.Open "select * from INSPECT Order by InsDOI DESC", db, , adLockOptimistic

DBEngine.Idle dbFreeLocks
RS2.AddNew
iRecCnt = RS2.RecordCount
For iCnt = 1 To iRecCnt - 1
RS2.Fields(iCnt).Value = RSPrimary.Fields(iCnt)
Next
RS2.Update

When this code runs I get the error:
"Run-time error '-2147217887(80040e21)'"
"Multiple-step operation generated errors. Check each status value."

The code will allow only two fields to be added to the buffer before the above error occurs.
If I bypass the error and go to RS2.Update it does create the new record with the two fields.

Anybody got any ideas. It would be much appreciated!
Reply With Quote
  #2 (permalink)  
Old 01-27-04, 22:55
Rushi Rushi is offline
Registered User
 
Join Date: Jan 2004
Location: India
Posts: 62
You are running the loop for number of records times.
If you want to copy all fields of one record set to another record set, you must rum the loop for number of columns times.
So try changing the loop counter.
__________________
Regards,

Rushi
Reply With Quote
  #3 (permalink)  
Old 01-30-04, 23:31
VB6Data VB6Data is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
Thumbs up Problem solved.

You are right! I changed the loop to loop through the recordset fields count. However, this did not fix the problem.
The problem turned out to be: I am displaying the local database in a grid. I passed the grid recordset as an object to the sub without thinking that the fields would not be in the same order as the server database because I used the data form wizard to populate the recordset. To solve the problem, I simply passed the key fields and created a new recordset. Now the fields match and the sub works. What confused me was the error message.
Thanks very much for your help. I appreciate it very much.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On