Results 1 to 2 of 2

Thread: Help saving XML table to a database

  1. #1

    Thread Starter
    Registered User jkw119's Avatar
    Join Date
    Oct 2001
    Location
    Pittsburgh
    Posts
    256

    Help saving XML table to a database

    If anyone has any Ideas, I would greatly appreciate any help, tutorials or anything. All i seem to find is saving a table from the database to xml, but nothing on doing the opposite.

    I have the following code...

    VB Code:
    1. Imports System
    2. Imports System.Data
    3. Imports System.Diagnostics
    4. Imports eInfoDesigns.dbProvider.MySqlClient
    5.  
    6. Sub Main()
    7.  
    8. Dim DataSource As String = "mliwebsvr"
    9. Dim Database As String = "test"
    10. Dim UserID As String = "UserID"
    11. Dim Password As String = "Password"
    12.  
    13. '  The connection, with command loggin on.  Connection pooling is
    14. '  activated by default, but can be turned off by adding
    15. '  the POOLING=false flag.
    16.  
    17.  Dim dbConnection As New MySqlConnection("Data Source=" + DataSource + _
    18. ";Database=" + Database + ";" + "User ID=" + UserID + ";Password=" _
    19.  + Password + ";COMMAND LOGGING=false")
    20. dbConnection.Open()
    21.  
    22. Dim AdapterCommand As New MySqlCommand()
    23. Dim Adapter As New MySqlDataAdapter()
    24.  
    25. AdapterCommand.Connection = dbConnection
    26. Adapter.SelectCommand = AdapterCommand
    27.  
    28. Dim BeamData As New DataSet()
    29. BeamData.ReadXml("a5_optimum_1.xml")
    30.  
    31. Adapter.InsertCommand.Parameters.Add(BeamData.Tables(0))
    32.  
    33. Adapter.Fill(BeamData)
    34. Adapter.Update(BeamData)
    35.  
    36. dbConnection.Close()
    37. End Sub

    The question I have is, is it possible to do what i am doing? All i need to do is simply write the XML file to the Database, by putting it in a new table. When you use the readxml command, the file is put in the default Table named (Table(0)). How can i then save this to the database. If anyone can help me out, I would greatly appreciate it.

    Thank you..
    Last edited by jkw119; Jan 24th, 2003 at 09:42 AM.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If there is no table with those fields then you'd have to first make the table then fill in the proper update query and do what you are doing. Unlike the ReadXML method of a dataset that also adds the structure an actual database can not add the structure of the table on the fly like that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width