Problem with Count Expression and DataTable

  • Thread starter Thread starter VTOcin
  • Start date Start date
V

VTOcin

Hello,

I created an XML file using the DataTable.WriteXML with the follwing
format:

Dim ACES_FLIGHT_SCHEDULE As New DataTable("ACES_FLIGHT_SCHEDULE")
'Add columns to the ACES FLight Schedule Table
ACES_FLIGHT_SCHEDULE.Columns.Add("Origin_Airport_ID",
Type.GetType("System.String"))
ACES_FLIGHT_SCHEDULE.Columns.Add("Destination_Airport_ID",
Type.GetType("System.String"))
ACES_FLIGHT_SCHEDULE.Columns.Add("Aircraft_Type",
Type.GetType("System.String"))
ACES_FLIGHT_SCHEDULE.Columns.Add("Departure_Time",
Type.GetType("System.String"))
ACES_FLIGHT_SCHEDULE.Columns.Add("Flight_Served",
Type.GetType("System.String"))

Then I read in the XML file with DataTable.ReadXML as follows:

Dim ACES_FLIGHT_SCHEDULE As New DataTable("ACES_FLIGHT_SCHEDULE")
ACES_FLIGHT_SCHEDULE.ReadXml("XMLTableName.xml")

However, when I perform the count it return an error: "Cannot find
field "Origin_Airport_ID":

Dim Origin_Airports As New DataTable
Origin_Airports.Columns.Add("Origin Airport ID").Expression =
"Count(Child(ACES_FLIGHT_SCHEDULE).Origin_Airport_ID)"

Any ideas ?

Thanks,

Nick,
 
Have you tried binding your datatable to a datagrid to view what's actually
in the table? Usually visualizing the data in a grid helps me find problems.
 
Hello VTOcin,

You're using the 'child' moniker and unless you have two tables that have
a relationship (signifying you're using a complete DataSet), child doesn't
know where to find the child table. I get the sense that we're missing a
lot of the code here. Maybe if you explain what you're trying to accomplish
instead of the specific error.

Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
 
Hi,

I'm trying to convert my old VB6 code to VB2005. I was using a MDB
database and a SQL statement to do a GROUP BY COUNT. I have been
struggling to find a clear and simple VB2005 example on how to do that.
Basically I have something similar to a Customer Table and an Orders
Table. Both have the CustomerID field. Now I want to count the orders
for each customer. However, I have been unable to get this to work. Any
clear VB2005 example code would be greatly appreciated (From creating
the dataset, relationships, etc...). All the code I have been coming
across is for C#.

Thanks,

Nick,
 
Back
Top