My company has a VB6 application that accesses SQL Server 2005. Our
consultants demo this application from laptops that have SQL Express
installed. Periodically we need to repopulate the "demo" databases with data
from our development server. This should be done by the consultants who will
NOT have intimate knowledge of SQL Server therefore I built a small VB
application to:
1. Persist data from the development server to XML files
2. Open an ADO recordset with the XML files as the source, connect to the
"target" server (on the laptop) and update the recordset.
(Assume I have already cleared the target tables and reset IDENTITY counters)
Everything works except my .UpdateBatch() call when connected to the
"target" server - I do NOT get an error, the data simply doesn't appear.
Below is a sample of the code I use to import the XML file.
Dim adoRS As New ADODB.Recordset
With adoRS
.Open "C:\Data\Address.xml", , adOpenStatic, adLockBatchOptimistic,
adCmdFile
.ActiveConnection = strConn '< this is a valid connection string to my
target database, I have also tried an open ADODB.Connection object
.UpdateBatch '< update appears to fail but no error generated
Set .ActiveConnection = Nothing
.Close
End With
I do not understand why the table is not populated.
I did notice that the XML file has a reference to the DB name on the old
server, the DB name on the target server will be different.
Any help greatly appreciated.
Regards,
Jim Leach
Jan Hyde (VB MVP) - 16 Apr 2008 09:08 GMT
Jim Leach <JimLeach@discussions.microsoft.com>'s wild
thoughts were released on Tue, 15 Apr 2008 12:26:02 -0700
bearing the following fruit:
>My company has a VB6 application that accesses SQL Server 2005. Our
>consultants demo this application from laptops that have SQL Express
[quoted text clipped - 35 lines]
>
>Jim Leach
If you don't mind the suggestion of a third party tool,
Red-Gate had a tool that alows you to quickly create a setup
program that your consultants can run and it will
automatically add all your new data, as well as implement
any table changes etc
http://www.red-gate.com/products/SQL_Packager/index.htm
--
Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde
roger - 20 Apr 2008 03:10 GMT
> My company has a VB6 application that accesses SQL Server 2005. Our
> consultants demo this application from laptops that have SQL Express
[quoted text clipped - 11 lines]
> Everything works except my .UpdateBatch() call when connected to the
> "target" server - I do NOT get an error, the data simply doesn't appear.
Does your XML look like this?
<rs:data>
<z:row etc... />
<z:row etc... />
</rs:data>
Try making it look like this...
<rs:data>
<rs:insert>
<z:row etc... />
<z:row etc... />
</rs:insert>
</rs:data>
Or, if you use a recordset to produce the XML file.
Try adding a new record using rs.addnew, then save as XML.
If you open the file in notepad, you will see the difference between new and
existing records.

Signature
roger
William Vaughn [MVP] - 30 Apr 2008 17:57 GMT
I can think of a half-dozen ways off the top of my head to do this and using
this approach would not be on the list--not even close.
I suggest using Bulk Copy, Detach/Attach, SSIS script, Backup/Restore,
Synchronization or ADO.NET SqlBulkCopy. But XML to Recordsets?

Signature
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
> My company has a VB6 application that accesses SQL Server 2005. Our
> consultants demo this application from laptops that have SQL Express
[quoted text clipped - 38 lines]
>
> Jim Leach