[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 675
  • Last Modified:

Load XML into a Dataset and Update DataSource( VB.NET)

Hello Experts,

       I have an XML file and i need to fill a dataset using that XML file and update the same in the data source (Say SQL Server). I am aware that many ways are there but i need to choose an optimistic procedure for this. Please Suggest a  Way to Do this.......Thanks in Advance.....

I try to do this in VB.NET and SQL Server


Regards..,
Thiyagz
0
thiyagz
Asked:
thiyagz
1 Solution
 
iboutchkineCommented:
'save xml to dataset
ds.ReadXml(YourXMLFIle)

now you can read your dataset and do all the updates to the SQL table
0
 
thiyagzAuthor Commented:
Friends.....,

     An Addition to the Question...? I need to add the data in the XML file in new table....Please Suggest me Some Code Samples...Thanks in Advance...

With Regards,
Thiyagz
0
 
spackdCommented:
thiyagz,
I am sure this is not the easiest method but you could do something like:
        Dim x As New Dataset1()
        Dim TblName As String = x.DataSetName
        Dim ColCtr As Integer
        Dim SqlString As String = "CREATE TABLE " & TblName & " ("

        Do While ColCtr < x.Tables(0).Columns.Count
            SqlString = SqlString & x.Tables(0).Columns(ColCtr).ColumnName.ToString() & " "
            SqlString = SqlString & x.Tables(0).Columns(ColCtr).DataType.ToString() & ", "
            ColCtr = ColCtr + 1
        Loop
        SqlString = SqlString & ")"

Then run this SqlString against the DB to create the table. I haven't run this code, so it may not be perfect, but should give you an idea.
-spackd
0
 
Bob LearnedCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by iboutchkine

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now