Home All Groups Group Topic Archive Search About

Problem with Count Expression and DataTable

Author
1 Aug 2006 1:44 PM
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,

Author
2 Aug 2006 2:41 PM
Keith
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.

Show quote
"VTOcin" wrote:

> 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,
>
>
Author
2 Aug 2006 3:28 PM
Shawn Wildermuth (C# MVP)
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

Show quote
> 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,
>
Author
2 Aug 2006 5:02 PM
VTOcin
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,

Shawn Wildermuth (C# MVP) wrote:
Show quote
> 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
>
> > 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,
> >

AddThis Social Bookmark Button