[RESOLVED] [2005] readXML populate different Tables
Ok. I Export two tables in XML using writeXML and i want to update another database with the same table schema with these XML tables.
Below is the Update code and Exported XML i am trying to use.
So far No Luck. where am i going wrong?
Code:
thanks shakti5385, i would rather you read my first post before posting any further. It describes what i am doing. As indicated,i am using 2005, and as indicated again, i am using readXML.
I have scratched my head and failed to get it,searched through the cyber but failed to get an answer. I thought it was the table name but after specifying the table name, i cant still have it. Some one help my head!
Ok...when i catch the exception, it tells me that object reference not set o an instance of object.
And when i remove the try catch block..i see the exception is here.
da1.InsertCommand.Parameters.Add(dsXMLImport.Tables(0).TableName).
Thanks stanav. there is no command text, i thought that the insertCommand given the tablename as the parameter can replace the insertcommand text.
I have tried to instantiate the insert command but still i get an exception on the same line saying...
"The OleDbParameterCollection only accepts non-null OleDbParameter type objects, not String objects."
I dont understand this now!...
i thought the parameter i am mean't to pass here should be the name of the first table in the XML! so if it does not allow this, then what can i pass?!
below is my code.
i would use insert statements and add fields as parameters to the insertcommand, but i want to import more than 10 tables with each having a minimum of 10 fields! So hardcording more than 10 insert command texts with each having 10 fields passed as parameters to the insert command would be alot of code.
Ok. i got it work.
Here is what i did.
Created an SQL statement, a new adapter and a new insertCommand
read my XML, inserted parameters for the insertCommand with items from the dataset.
Updated the dataAdapter...and Bingo i imported one table.
I think i will stay with this,which implies if i have 10 tables to update on the Fly, i will repeat the same routine for all the 10 tables.
Re: [RESOLVED] [2005] readXML populate different Tables
maps, if you don't mind could you please post your code. I have been trying to accomplish the same thing now for a couple of weeks and have not been successful.
Re: [RESOLVED] [2005] readXML populate different Tables
Here you are.
You will need to modify it a little to suit your needs.
VB Code:
Private Sub update_tblPopulatedPlaces_fromXML()
Dim dsXMLImport As New DataSet
myConn = New OleDbConnection(strAccessConn)
Dim strSQL As String = "INSERT INTO tblPopulatedPlaces(AdminBdry1_ID,AdminBdry2_ID,AdminBdry3_ID,AdminBdry4_ID,PPname,uid_Created,date_Created,uid_Modified,date_Modified)" & _