How do you make the contents of a table the same as a recordset read in from XML file ?
– I want to back up a table, so have used the ADO .Save to persist it to disk in XML format, I can then open it but I can’t seem to get the data back into the table. Originally I was using the .UpdateBatch and check the .Status was adRecUnmodified but when I tried a test, i.e. deleted all the records from the original table and tried the load, no records were inserted
I know I can do this other ways, even making SQL INSERT strings, but as ADO is the Microsoft way, I thought this simple exercise would be a good start
As a further question, how does the XML file store the status of changed records
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
ADO recordset as XML (97/SR2)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » ADO recordset as XML (97/SR2)
- This topic has 6 replies, 2 voices, and was last updated 22 years, 12 months ago.
AuthorTopicWSsculshaw
AskWoody LoungerMay 29, 2002 at 7:11 am #371547Viewing 0 reply threadsAuthorReplies-
WScharlotte
AskWoody LoungerMay 29, 2002 at 12:18 pm #590891The method you want is .UpdateBatch.
Here’s a routine you can adapt to your uses. This was written for Access 2000, so it uses CurrentProject.Connection, which will fail in A97 and which will have to be replaced with an alternate connection method. The A97 provider would be Jet 3.51, of course.
Public Function SyncRecordset(ByVal strPersistedName As String, _ ByVal strFilePath As String) As Boolean On Error GoTo Proc_err 'update the strRowSource from the persisted recordset Dim rst As ADODB.Recordset Dim cnn As ADODB.Connection Dim errCurr As ADODB.Error 'open a connection to the database Set cnn = CurrentProject.Connection 'for other than the current db you could use: ' Set cnn = New ADODB.Connection ' With cnn ' .Provider = "Microsoft.Jet.OLEDB.4.0" ' .ConnectionString = "data source=" _ & strFilePath & "PersistedRst.mdb" ' .Mode = adModeReadWrite ' .Open ' End With 'open the persisted recordset Set rst = New ADODB.Recordset With rst .CursorLocation = adUseClient .CursorType = adOpenKeyset .LockType = adLockBatchOptimistic .Open strFilePath & "" & strPersistedName, cnn, , , adCmdFile 'You can set the activeconnection property 'separately by attaching the rst to an active 'connection instead of in the open method ' .ActiveConnection = cnn 'NOTE: This must come AFTER opening ' the persisted recordset 'Using this will cause at least 'some syncs to fail '.Filter = adFilterAffectedRecords If Not .BOF And Not .EOF Then 'update the source with all records from the recordset .UpdateBatch SyncRecordset = True Else MsgBox "There are no records eligible to sync." End If End With Proc_exit: On Error Resume Next Set rst = Nothing Set cnn = Nothing Exit Function Proc_err: If cnn.Errors.Count > 0 Then For Each errCurr In cnn.Errors MsgBox "ADO error " & errCurr.Number & "--" & errCurr.Description Next errCurr cnn.Errors.Clear ElseIf Err 0 Then MsgBox "application error " & Err.Number & "--" & Err.Description End If Resume Proc_exit End Function
-
WSsculshaw
AskWoody LoungerMay 29, 2002 at 4:03 pm #590956Thanks Charlotte
Changed the code for A97 and 3.51, but it doesn’t do what I want, or the much more likely, it doesn’t do want I think it should
i.e. if I delete all the records in the access table, then run the SyncRecordset against the XML file, would the .UpdateBatch create new records
or do I have to create a recordset from the XML, then loop through every record, doing an .AddNew for each
– this seems a poor approach
– I suppose I’m wondering if there is someway to make the ‘table’ equal the recordset in one operation -
WScharlotte
AskWoody LoungerMay 30, 2002 at 2:06 am #591064I don’t understand the question. What are you *trying* to do. You can keep editing the XML recordset until you have it the way you want it. If you delete records in the XML recordset, they’ll be deleted in Access when you sync the two, and the same is true of adding records in the XML recordset. If you delete records in Access rather than from the persisted recordset, you’ll probably run into errors and may not be able to sync the table at all.
-
WSsculshaw
AskWoody LoungerMay 30, 2002 at 8:54 am #591105Ah, you last comment may explain my problem
– I need to save the data from one of the tables, then maybe reload it from the data file into the table at a later time, so I’m trying to put together some that will take the data from the file and either insert or amend the records into the Access table
– main reason is to persist values for different users on different sites, whenever I give them a new copy of the database (I know it’d be better to split into a front-end + data back-end, but I’ve got to work with the practices set-up previously)
– I went with the XML as it gave me an opportunity to play with ADO -
WScharlotte
AskWoody LoungerMay 30, 2002 at 12:17 pm #591156It sounds like you may need to look into replication rather than ADO, but DO NOT try replication on an unsplit database because you don’t want to replicate the front end, only the data. Trust me, I’ve replicated front ends and it is only doable if all your replicas are within walking distance.
As for working with practices previously set up, don’t fall into that trap. It’s a good way to lose your sanity fast and you’re the one who gets the blame for failures, not the person who set it up in the first place. Persuade them that “advances in the technology” now make it more desireable to split the database.
-
WSsculshaw
AskWoody Lounger
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Login screen icon
by
CWBillow
2 hours, 56 minutes ago -
AI coming to everything
by
Susan Bradley
46 minutes ago -
Mozilla : Pocket shuts down July 8, 2025, Fakespot shuts down on July 1, 2025
by
Alex5723
10 hours, 24 minutes ago -
No Screen TurnOff???
by
CWBillow
10 hours, 46 minutes ago -
Identify a dynamic range to then be used in another formula
by
BigDaddy07
11 hours, 19 minutes ago -
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
22 hours, 55 minutes ago -
How well does your browser block trackers?
by
n0ads
9 hours, 13 minutes ago -
You can’t handle me
by
Susan Bradley
1 hour, 41 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
1 hour, 50 minutes ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
1 day, 10 hours ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
13 hours, 48 minutes ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
1 day, 10 hours ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
1 day, 10 hours ago -
Lumma malware takedown
by
EyesOnWindows
23 hours, 2 minutes ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
1 day, 19 hours ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
1 day, 19 hours ago -
Meet Gemini in Chrome
by
Alex5723
1 day, 23 hours ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
1 day, 23 hours ago -
Trump signs Take It Down Act
by
Alex5723
2 days, 7 hours ago -
Do you have a maintenance window?
by
Susan Bradley
12 hours, 22 minutes ago -
Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms
by
Nibbled To Death By Ducks
1 day, 9 hours ago -
Cox Communications and Charter Communications to merge
by
not so anon
2 days, 11 hours ago -
Help with WD usb driver on Windows 11
by
Tex265
3 hours, 7 minutes ago -
hibernate activation
by
e_belmont
2 days, 19 hours ago -
Red Hat Enterprise Linux 10 with AI assistant
by
Alex5723
2 days, 23 hours ago -
Windows 11 Insider Preview build 26200.5603 released to DEV
by
joep517
3 days, 2 hours ago -
Windows 11 Insider Preview build 26120.4151 (24H2) released to BETA
by
joep517
3 days, 2 hours ago -
Fixing Windows 24H2 failed KB5058411 install
by
Alex5723
1 day, 22 hours ago -
Out of band for Windows 10
by
Susan Bradley
3 days, 7 hours ago -
Giving UniGetUi a test run.
by
RetiredGeek
3 days, 14 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.