DataColumn.Expression problem in Dataset designer

shalan99

Active member
Joined
Jun 1, 2007
Messages
32
Programming Experience
Beginner
Hi everyone,

Ok, I hope I can be thorough with my explanation....In my VB.net 2005 app have a databse with 2 tables - structure as follows:

Dept
DeptID (PK),​
DeptName​

Documents
DocumentID (PK),​
DocumentName,​
Active,​
DeptID (FK on Table1)​


Now, I have pulled in these 2 tables into my Dataset. In the dataset designer, I add a column to Dept and call it NumberActive (this is supposed to be a count of rows similar to a T-SQL statement: ...where Documents.DeptID = Dept.DeptID AND Documents.Active = True)

In a listbox bound to DeptBindingSource, another label on the form is supposed to be bound to NumberActive, so everytime the Listbox's SelectedIndexChanged event fires, the label will be refreshed with a count of Active documents for that department. Unfortunately, the label shows as '0' when I the form loads or when the selected index changes.

The expression that I am using for the in-designer-added column, NumberActive, is as follows:

Count(Child(FK_Documents_Dept).Active) = True

I have not done any additional coding behind the scenes, and I'm not sure if its necessary? Getting nowehere also searching Google.

Any help with this would be very much appreciated :)!

Thanx guys/gals!
-Shalan99
 
Hangon..

Count(something) = True


How can a count equate to a boolean?


Perhaps you should define an expression on your child:

ActiveNum.Expression = "Iif(Active, 1, 0)"

Then have your parent sum this:

Sum(Child.ActiveNum)



-

I.e. turn your boolean Active True/False, into a number 1/0

Then sum them all

I dont know if this will work:

Sum(Iif(Child.Active, 1, 0))


It might be too complex for the client side to handle

-

If none of this works, do it in a query
 
Back
Top