Issue SQL Statement with a DataTable in VB 2005

V

VTOcin

Hi,

I'm creating a DataTable from an XML file:

Dim ACES_FLIGHT_SCHEDULE As New DataTable("ACES_FLIGHT_SCHEDULE")
ACES_FLIGHT_SCHEDULE.ReadXml(ACES_Project_Dir + "\FlightSchedule_" +
CaseYear + "_Quarter" + Quarter + "_" + SATSAirportSetName & ".xml")

Then I would like to execute the following SQL Statement on the
DataTable and save the results in another DataTable:

SQL_Query_String = "SELECT " & ACES_FLIGHT_SCHEDULE & " GROUP BY " &
"Origin_Airport_ID"

where Oring_Airport_ID is my field to be grouped by.

How can I make this work ? Sample code would be greatly appreciated.

Thank you,

Nick,
 
M

Marina Levit [MVP]

That isn't going to happen. A DataTable is not an in memory database. It's
basically just some rows and columns. The most it can do is some limited
selection so you can do some filtering, but even that is very basic and
nothing like what you can do in a query.

You are probably more likely to get what you want by using XPATH and/or XSL
to transform the data into the format you are looking for.
 
Z

zackary.evans

you can't actually execute ANSI SQL against a datatable.

The DataTable.Select(filterexpression, sort order) is really the only
tool that you have, it works pretty much like a SQL select but with
much narrower capabilities. This returns an array of DataRows which
could then be inserted into a second DataTable

check out this for options available to form filter and sort
expressions -
http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top