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
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
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 23 years 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
-
Windows AI Local Only no NPU required!
by
RetiredGeek
3 hours, 28 minutes ago -
Stop the OneDrive defaults
by
CWBillow
6 hours, 31 minutes ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
8 hours, 56 minutes ago -
X Suspends Encrypted DMs
by
Alex5723
11 hours, 8 minutes ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
11 hours, 26 minutes ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
12 hours, 3 minutes ago -
OpenAI model sabotages shutdown code
by
Cybertooth
12 hours, 40 minutes ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
50 minutes ago -
Enabling Secureboot
by
ITguy
7 hours, 50 minutes ago -
Windows hosting exposes additional bugs
by
Susan Bradley
20 hours, 35 minutes ago -
No more rounded corners??
by
CWBillow
16 hours, 23 minutes ago -
Android 15 and IPV6
by
Win7and10
6 hours, 8 minutes ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
1 day, 8 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
1 day, 11 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
1 day, 6 hours ago -
Windows Update orchestration platform to update all software
by
Alex5723
1 day, 18 hours ago -
May preview updates
by
Susan Bradley
1 day, 6 hours ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
21 hours, 55 minutes ago -
Just got this pop-up page while browsing
by
Alex5723
1 day, 11 hours ago -
KB5058379 / KB 5061768 Failures
by
crown
1 day, 8 hours ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
10 hours, 23 minutes ago -
At last – installation of 24H2
by
Botswana12
2 days, 10 hours ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
7 hours, 10 minutes ago -
RyTuneX optimize Windows 10/11 tool
by
Alex5723
2 days, 22 hours ago -
Can I just update from Win11 22H2 to 23H2?
by
Dave Easley
21 hours, 6 minutes ago -
Limited account permission error related to Windows Update
by
gtd12345
3 days, 12 hours ago -
Another test post
by
gtd12345
3 days, 12 hours ago -
Connect to someone else computer
by
wadeer
3 days, 6 hours ago -
Limit on User names?
by
CWBillow
3 days, 9 hours ago -
Choose the right apps for traveling
by
Peter Deegan
2 days, 23 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.