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