Results 1 to 6 of 6

Thread: execute sql command with xml file

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Location
    Hanoi.VietNam
    Posts
    12

    Question execute sql command with xml file

    hi guys!
    i am beginning with xml document.and i have a question:
    how can i execute a sql query with a DataTable in xml document
    thanks alot !

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: execute sql command with xml file

    You'll have to explain that a bit more clearly. Are you saying that you have an XML file containing a serialised DataTable? Where's the query?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Location
    Hanoi.VietNam
    Posts
    12

    Re: execute sql command with xml file

    i've back
    please help me!
    as you said. i have an xml file named test.xml:
    Code:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <doc>
      <song>
        <id>1</id>
        <name>Unbreakable</name>
        <artist>Westlife</artist>
      </song>
      <song>
        <id>2</id>
        <name>ShowMeTheMeaningOfBeingLonely</name>
        <artist>B.S.B</artist>
      </song>
    </doc>
    so i have a datatable named: 'song' in this file.
    then in my program,i use these statements:
    Code:
    DataSet ds = new DataSet();
                ds.ReadXml("test.xml");
                DataTable da = new DataTable();
                da = ds.Tables["song"];
    now i want to execute many sql commands with this datatable.
    if it is an access database or sql database,i would use oledb or ado.net
    but now it is an xml file.
    please help me!
    thanks!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: execute sql command with xml file

    You are mistaken. You would use OleDb or SqlClient to execute an SQL query to retrieve data from Access or SQL Server into a DataTable. You've already got a DataTable. If you want to filter a Datatable then you can either call its Select method or set its DefaultView.RowFilter property. Unless you're using .NET 3.x and LINQ though, you can't actually query a DataTable.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Location
    Hanoi.VietNam
    Posts
    12

    Re: execute sql command with xml file

    i see what you said.
    before,i believed that there is a Class in .net to help me connect with xml database and manipulate with it easily,and can execute sql commands.
    thanks.

  6. #6
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: execute sql command with xml file

    Indeed, and jmcilhinney has already hinted at it - XLINQ
    Slightly less verbose example
    You'll need Visual Studio 2008 - the Express editions are free

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