Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding XML to a Table
Message
From
28/07/2003 10:13:30
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, United States
 
General information
Forum:
ASP.NET
Category:
Databases
Miscellaneous
Thread ID:
00813556
Message ID:
00814098
Views:
9
Hi Cathi,

Perhaps I'm missing something, but the dataset.merge method is used for merging two datasets. I want to merge two tables in a single dataset. Is there a different command or what am I missing?

Jim

>Jim,
>
>Have you looked at the DataSet.Merge method? It allows you to combine different DataTables together.
>
>>Maybe I'm asking the wrong question...
>>
>>I will have one dataset with two tables in it (example table1 and table2). Table 2 will be originally from an XML file and table 1 will be from a database. I want to take what is in table 2 and place it into table 1. If a record in table 2 (the XML) is already in table 1 I want to update the record. If a record is new then I would like it appended or inserted into table 1. Can this be done with the command builder or is there a different/better way to accomplish it?
>>
>>Jim
>>
>>>Jim,
>>>
>>>Sorry I didn't reply sooner ... I was at lunch.
>>>
>>>>>The XML is read into a dataset earlier in the program. I want to take the data in that dataset and update a database table with it. <
>>>
>>>OK, in that case, it looks like you're overwriting the data with the .Fill() method.
>>>
>>>        oParentForm.daBrowse.Fill(dsGridData, oTableImport.Table)
>>>
>>>The above command is filling the table in dsGridData ... now, if you have already filled the table earlier, it's getting overwritten with this command. So, just leave out the .Fill method and see what happens ....
>>>
>>>~~Bonnie
>>>
>>>
>>>
>>>>
>>>>Jim
>>>>
>>>>>Jim,
>>>>>
>>>>>I guess I don't get what you're trying to do ... your code isn't doing anything with XML from what I can see, unless I missed something (not being a VB kind of person).
>>>>>
>>>>>~~Bonnie
>>>>>
>>>>>
>>>>>>All,
>>>>>>
>>>>>> I have created a program that works with both XML and SQL Server. One of the things I want to be able to do is add XML data to a table that the user selects. I have tried for hours and hours to get this to work with the Command builder object, but have failed. The code I have is below. My questions are What is wrong with the code? Second, Is there a better way to import XML data into a dataset?
>>>>>>
>>>>>>Any thoughts would be appreciated!
>>>>>>
>>>>>>Here's the code:
>>>>>> Dim cmdBuilder As SqlClient.SqlCommandBuilder
>>>>>> Dim oTableImport As New TableImport(Me.oParentForm.activeTableName)
>>>>>> oTableImport.ShowDialog()
>>>>>> Me.oParentForm.activeConnection.Open()
>>>>>> oParentForm.daBrowse.SelectCommand.CommandType = CommandType.Text
>>>>>> oParentForm.daBrowse.SelectCommand.CommandText = "Select * from " + oTableImport.Table
>>>>>> oParentForm.daBrowse.SelectCommand.Connection = oParentForm.activeConnection
>>>>>> cmdBuilder = New SqlClient.SqlCommandBuilder(oParentForm.daBrowse)
>>>>>> oParentForm.daBrowse.Fill(dsGridData, oTableImport.Table)
>>>>>> cmdBuilder.GetDeleteCommand()
>>>>>> cmdBuilder.GetUpdateCommand()
>>>>>> cmdBuilder.GetInsertCommand()
>>>>>> oParentForm.daBrowse.Update(dsGridData, oParentForm.activeTableName)
>>>>>> dsGridData.AcceptChanges()
>>>>>> Me.oParentForm.activeConnection.Close()
Thanks

Jim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform