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 !
Printable View
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 !
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?
i've back
please help me!
as you said. i have an xml file named test.xml:
so i have a datatable named: 'song' in this file.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>
then in my program,i use these statements:
now i want to execute many sql commands with this datatable.Code:DataSet ds = new DataSet();
ds.ReadXml("test.xml");
DataTable da = new DataTable();
da = ds.Tables["song"];
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!
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.
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.
Indeed, and jmcilhinney has already hinted at it - XLINQ
Slightly less verbose example
You'll need Visual Studio 2008 - the Express editions are free