|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
UPDATE a XML file problemI have this code vbscript code for updata a xml file in to a database. (sample) . I need to update a xml from a database1 to another database2. As the results from the database1 generally changes a every week, I need to export all the data to database2. I would like to update this database3. ' VBScript source code set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.3.0") objBL.ConnectionString = "provider=SQLOLEDB.1;datasource=localhost;database=MyDatabase;integrated security=SSPI" objBulkLoad.IgnoreDuplicateKeys = True objBulkLoad.KeepIdentity = False objBulkLoad.KeepNulls = True objBulkLoad.ForceTableLock = True objBulkLoad.SchemaGen = True objBulkLoad.SGUseID = True objBulkLoad.SGDropTables = True objBL.ErrorLogFile = "c:\error.log" objBL.Execute "customersmapping.xml", "customers.xml" Set objBL = Nothing and I update this xml file and all is ok <?xml version="1.0" encoding="utf-8" ?> <ROOT xmlns="custommers.xsd"> <Customers> <CustomerId>1111</CustomerId> <CompanyName>Sean Chai</CompanyName> <City>NY</City> </Customers> <Customers> <CustomerId>1112</CustomerId> <CompanyName>Tom Johnston</CompanyName> <City>LA</City> </Customers> <Customers> <CustomerId>1113</CustomerId> <CompanyName>Institute of Art</CompanyName> </Customers> <Customers> <CustomerId>1156</CustomerId> <CompanyName>School</CompanyName> </Customers> <Customers> <CustomerId>189</CustomerId> <CompanyName>TOTO</CompanyName> </Customers> </ROOT> Now i would like to upload this file <?xml version="1.0" encoding="utf-8" ?> <ROOT xmlns="custommers.xsd"> <Customers> <CustomerId>1111</CustomerId> <CompanyName>Sean Chai</CompanyName> <City>NY</City> </Customers> <Customers> <CustomerId>1112</CustomerId> <CompanyName>Tom Johnston</CompanyName> <City>LA</City> </Customers> <Customers> <CustomerId>1113</CustomerId> <CompanyName>Institute of Art</CompanyName> </Customers> <Customers> <CustomerId>1156</CustomerId> <CompanyName>School</CompanyName> </Customers> <Customers> <CustomerId>189</CustomerId> <CompanyName>Laria</CompanyName> </Customers> <Customers> <CustomerId>156</CustomerId> <CompanyName>Jonathan</CompanyName> <City>NY</City> </Customers> </ROOT> and I cannot do it! because it doesn't take on consideration the changes on this file... How can I update this the changes into my database3. Any suggestion. Ina Assuming SQL Server:
Run the XML into a stored procedure that prunes out items that are exactly alike and only runs the changes. With OPEN XML, you can query XML like a database table. ANother option is to do an XML bulk load into a "temp" table and run the changes there. Otherwise: You may have to run through the records one by one to get the Customer IDs and then query the database to pull the same information. You can then update those that have changed by looping through the records and then calling Update() on the DataAdapter. -- Show quoteGregory A. Beamer ************************************************* Think Outside the Box! ************************************************* "Ina" <roberta.inal***@gmail.com> wrote in message news:1151414051.966037.277500@i40g2000cwc.googlegroups.com... > Good morning, > > I have this code vbscript code for updata a xml file in to a database. > (sample) . I need to update a xml from a database1 to another > database2. As the results from the database1 generally changes a every > week, I need to export all the data to database2. I would like to > update this database3. > > ' VBScript source code > > set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.3.0") > > objBL.ConnectionString = > "provider=SQLOLEDB.1;datasource=localhost;database=MyDatabase;integrated > security=SSPI" > > objBulkLoad.IgnoreDuplicateKeys = True > objBulkLoad.KeepIdentity = False > objBulkLoad.KeepNulls = True > objBulkLoad.ForceTableLock = True > objBulkLoad.SchemaGen = True > objBulkLoad.SGUseID = True > objBulkLoad.SGDropTables = True > > objBL.ErrorLogFile = "c:\error.log" > objBL.Execute "customersmapping.xml", "customers.xml" > Set objBL = Nothing > > > and I update this xml file and all is ok > > <?xml version="1.0" encoding="utf-8" ?> > <ROOT xmlns="custommers.xsd"> > <Customers> > <CustomerId>1111</CustomerId> > <CompanyName>Sean Chai</CompanyName> > <City>NY</City> > </Customers> > <Customers> > <CustomerId>1112</CustomerId> > <CompanyName>Tom Johnston</CompanyName> > <City>LA</City> > </Customers> > <Customers> > <CustomerId>1113</CustomerId> > <CompanyName>Institute of Art</CompanyName> > </Customers> > <Customers> > <CustomerId>1156</CustomerId> > <CompanyName>School</CompanyName> > </Customers> > <Customers> > <CustomerId>189</CustomerId> > <CompanyName>TOTO</CompanyName> > </Customers> > </ROOT> > > Now i would like to upload this file > > <?xml version="1.0" encoding="utf-8" ?> > <ROOT xmlns="custommers.xsd"> > <Customers> > <CustomerId>1111</CustomerId> > <CompanyName>Sean Chai</CompanyName> > <City>NY</City> > </Customers> > <Customers> > <CustomerId>1112</CustomerId> > <CompanyName>Tom Johnston</CompanyName> > <City>LA</City> > </Customers> > <Customers> > <CustomerId>1113</CustomerId> > <CompanyName>Institute of Art</CompanyName> > </Customers> > <Customers> > <CustomerId>1156</CustomerId> > <CompanyName>School</CompanyName> > </Customers> > <Customers> > <CustomerId>189</CustomerId> > <CompanyName>Laria</CompanyName> > </Customers> > <Customers> > <CustomerId>156</CustomerId> > <CompanyName>Jonathan</CompanyName> > <City>NY</City> > > </Customers> > > </ROOT> > > and I cannot do it! because it doesn't take on consideration the > changes on this file... How can I update this the changes into my > database3. > > Any suggestion. > > Ina > |
|||||||||||||||||||||||