Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > ADO Data > Re: Problem wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 4270 of 4320
Post > Topic >>

Re: Problem with Expression Column

by "Mansoor A. Karim" <mansoorkarim@[EMAIL PROTECTED] > Jul 23, 2008 at 03:11 PM

My following piece of code draws on Northwind sample database, in
particular 
tables Orders and OrderDetails.

Having added DataTables based on Orders and OrderDetails to a DataSet, I 
then added the relation "FK_OrderDetails_Orders" to the dataset relating
the
two tables. Now I wish to add an expression column (namely OrderAmount) to

Orders datatable showing for each Orders row, sum total of the products
"OrderDetails.UnitPrice * OrderDetails.Quantity" for related child rows in

OrderDetails.

I tried following aggregate expression that seems a correct natural 
expression for the logic but code fails with run time error 
"SyntaxErrorException". Details of the error are also appended below the 
code.

//Code starts here
DataColumn expressionColumn;

expressionColumn = new DataColumn("OrderAmount", 
Type.GetType("System.Decimal"),
"SUM(Child(FK_OrderDetails_Orders).UnitPrice 
* Child(FK_OrderDetails_Orders).Quantity)");

NWindDataSet.Tables["Orders"].Columns.Add(expressionColumn);

Details of exception
SyntaxErrorException was unhandled
Syntax error in aggregate argument; expecting a single column argument
with
possible 'Child' qualifier.

I did manage a workaround by first adding an expression colum to the 
OrderDetails table (ItemAmount = UnitPrice*Quantity) and then taking the
aggregate of this child expression colum in the parent expression column.

I find msdn help quite vague on expression usage. The error suggests of a 
single column limit but is equally vague. Can anyone please find out
problem
with my expression code or explain this error more precisely.

Thanks
Mansoor
 




 3 Posts in Topic:
Re: Problem with Expression Column
"Mansoor A. Karim&qu  2008-07-23 15:11:43 
Re: Problem with Expression Column
"Bob Barrows [MVP]&q  2008-07-23 06:37:02 
Re: Problem with Expression Column
"Mansoor A. Karim&qu  2008-07-24 23:57:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 15:11:30 CST 2008.