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, 10 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
-
Office apps read-only for family members
by
b
26 minutes ago -
Defunct domain for Microsoft account
by
CWBillow
5 hours, 49 minutes ago -
24H2??
by
CWBillow
6 minutes ago -
W11 23H2 April Updates threw ‘class not registered’
by
WindowsPersister
3 hours, 7 minutes ago -
Master patch listing for April 8th, 2025
by
Susan Bradley
9 hours, 21 minutes ago -
TotalAV safety warning popup
by
Theodore Nicholson
2 hours, 47 minutes ago -
two pages side by side land scape
by
marc
1 day, 16 hours ago -
Deleting obsolete OneNote notebooks
by
afillat
1 day, 18 hours ago -
Word/Outlook 2024 vs Dragon Professional 16
by
Kathy Stevens
21 hours, 8 minutes ago -
Security Essentials or Defender?
by
MalcolmP
23 hours, 53 minutes ago -
April 2025 updates out
by
Susan Bradley
6 hours, 27 minutes ago -
Framework to stop selling some PCs in the US due to new tariffs
by
Alex5723
17 hours, 14 minutes ago -
WARNING about Nvidia driver version 572.83 and 4000/5000 series cards
by
Bob99
7 hours, 19 minutes ago -
Creating an Index in Word 365
by
CWBillow
1 day, 9 hours ago -
Coming at Word 365 and Table of Contents
by
CWBillow
1 day, 1 hour ago -
Windows 11 Insider Preview Build 22635.5170 (23H2) released to BETA
by
joep517
2 days, 13 hours ago -
Has the Microsoft Account Sharing Problem Been Fixed?
by
jknauth
2 days, 16 hours ago -
W11 24H2 – Susan Bradley
by
G Pickerell
2 days, 18 hours ago -
7 tips to get the most out of Windows 11
by
Alex5723
2 days, 16 hours ago -
Using Office apps with non-Microsoft cloud services
by
Peter Deegan
2 days, 9 hours ago -
I installed Windows 11 24H2
by
Will Fastie
16 hours, 10 minutes ago -
NotifyIcons — Put that System tray to work!
by
Deanna McElveen
2 days, 22 hours ago -
Decisions to be made before moving to Windows 11
by
Susan Bradley
3 hours, 21 minutes ago -
Port of Seattle says ransomware breach impacts 90,000 people
by
Nibbled To Death By Ducks
3 days, 6 hours ago -
Looking for personal finance software with budgeting capabilities
by
cellsee6
2 days, 14 hours ago -
ATT/Yahoo Secure Mail Key
by
Lil88reb
2 days, 14 hours ago -
Devices with apps using sprotect.sys driver might stop responding
by
Alex5723
3 days, 23 hours ago -
Neowin – 20 times computers embarrassed themselves with public BSODs and goofups
by
EP
4 days, 7 hours ago -
Slow Down in Windows 10 performance after March 2025 updates ??
by
arbrich
7 hours, 19 minutes ago -
Mail from certain domains not delivered to my outlook.com address
by
pumphouse
3 days, 16 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.