:plain:Hi there;
I'm racking my brains for a while and haven't found the solution for this:
[list=1]
[list]
[*]I'm using VS 2005 and a Type Dataset( WINFORM)
[*]I add two tables (Parent and child) with the proper relation
[*]I add a calculated column in the Parent table with the following expression (Parent.[columnname]).
[*]At run time the calculated column returns a null vale.
I don't really know what's wrong generating calculated columns with Type dataset.
No run-time error just only null vales ...please help.
Calculated columns in type datasetPlease help
Page 1 of 1
8 Replies - 2572 Views - Last Post: 14 April 2010 - 08:37 AM
Replies To: Calculated columns in type dataset
#2
Re: Calculated columns in type dataset
Posted 12 April 2010 - 04:57 AM
Take the "Parent." out. There is no table scope in the declaration. You can't look at other tables.
You can do this:
Not:
More here: http://msdn.microsof...n(v=VS.71).aspx
You can do this:
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add("Test");
dt.Columns.Add("ColAlpha", typeof(int));
DataColumn dc = dt.Columns.Add("ColBeta", typeof(int));
dc.Expression = "[ColAlpha]";
Not:
dc.Expression = "Test.[ColAlpha]";
More here: http://msdn.microsof...n(v=VS.71).aspx
#4
Re: Calculated columns in type dataset
Posted 14 April 2010 - 06:53 AM
Hi There:
I'm using VS 2205 in winForms (C#).I created a strong Type Dataset using the UIE wizard of VS2005. I added a couple of datatables parent-child with their relationship. I put a calculated column in the child table using Expresion= Parent.columnname.
On runtime the dataset return a null calculated column.
In another hand, I have tried another way around by I coding the dataset (untype) and the calculated column works smoothly.
Is it a bug of this version or I'm missing something?
PLEASE HELP !!!!!!
I'm using VS 2205 in winForms (C#).I created a strong Type Dataset using the UIE wizard of VS2005. I added a couple of datatables parent-child with their relationship. I put a calculated column in the child table using Expresion= Parent.columnname.
On runtime the dataset return a null calculated column.
In another hand, I have tried another way around by I coding the dataset (untype) and the calculated column works smoothly.
Is it a bug of this version or I'm missing something?
PLEASE HELP !!!!!!
#5
Re: Calculated columns in type dataset
Posted 14 April 2010 - 07:37 AM
The answer in your previous topic was insufficient?
#6
Re: Calculated columns in type dataset
Posted 14 April 2010 - 07:42 AM
Topics merged, there's no need for duplicate topics.
#7 Guest_chocus aterguss*
Re: Calculated columns in type dataset
Posted 14 April 2010 - 08:00 AM
Hi baavgai:
Thanks for the prompt reply but I;m still out..please notice that I have two Tableadapter(no one) in the dataset hence I want in the calculated column make reference to the Parent table...if I follow your indication VS compile an error "Cannot find column" in other words I have to prefix Parent. in order to lookup the column that I want in the another table.
There's nothing wrong with adding Parent. because if I changed the column name deliberately and the compiler inmediately pick up the mistaken column ...it means that my approach is correct, BUT I'M STILL DON'T UNDERSTAND WHY RETURN NULL.
Any help will be highly appreciated
awaiting ......
Thanks for the prompt reply but I;m still out..please notice that I have two Tableadapter(no one) in the dataset hence I want in the calculated column make reference to the Parent table...if I follow your indication VS compile an error "Cannot find column" in other words I have to prefix Parent. in order to lookup the column that I want in the another table.
There's nothing wrong with adding Parent. because if I changed the column name deliberately and the compiler inmediately pick up the mistaken column ...it means that my approach is correct, BUT I'M STILL DON'T UNDERSTAND WHY RETURN NULL.
Any help will be highly appreciated
awaiting ......
baavgai, on 12 April 2010 - 03:57 AM, said:
Take the "Parent." out. There is no table scope in the declaration. You can't look at other tables.
You can do this:
Not:
More here: http://msdn.microsof...n(v=VS.71).aspx
You can do this:
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add("Test");
dt.Columns.Add("ColAlpha", typeof(int));
DataColumn dc = dt.Columns.Add("ColBeta", typeof(int));
dc.Expression = "[ColAlpha]";
Not:
dc.Expression = "Test.[ColAlpha]";
More here: http://msdn.microsof...n(v=VS.71).aspx
#8 Guest_chocus aterguss*
Re: Calculated columns in type dataset
Posted 14 April 2010 - 08:06 AM
Hi baavgai:
Thanks for the prompt reply but I;m still out..please notice that I have two Tableadapter(no one) in the dataset hence I want in the calculated column make reference to the Parent table...if I follow your indication VS compile an error "Cannot find column" in other words I have to prefix Parent. in order to lookup the column that I want in the another table.
There's nothing wrong with adding Parent. because if I changed the column name deliberately and the compiler inmediately pick up the mistaken column ...it means that my approach is correct, BUT I'M STILL DON'T UNDERSTAND WHY RETURN NULL.
Any help will be highly appreciated
awaiting ......
Thanks for the prompt reply but I;m still out..please notice that I have two Tableadapter(no one) in the dataset hence I want in the calculated column make reference to the Parent table...if I follow your indication VS compile an error "Cannot find column" in other words I have to prefix Parent. in order to lookup the column that I want in the another table.
There's nothing wrong with adding Parent. because if I changed the column name deliberately and the compiler inmediately pick up the mistaken column ...it means that my approach is correct, BUT I'M STILL DON'T UNDERSTAND WHY RETURN NULL.
Any help will be highly appreciated
awaiting ......
#9
Re: Calculated columns in type dataset
Posted 14 April 2010 - 08:37 AM
Check your relation. Also, the docs are unclear how to handle multiple parents.
Assuming the relation is set correctly, Parent should work.
e.g.
Results:
Assuming the relation is set correctly, Parent should work.
e.g.
DataSet ds = new DataSet();
DataTable dt1 = ds.Tables.Add("Deparment");
dt1.Columns.Add("DeptId", typeof(int));
dt1.Columns.Add("Description", typeof(string));
dt1.Constraints.Add("PkDepartment", dt1.Columns["DeptId"], true);
DataTable dt2 = ds.Tables.Add("Employee");
dt2.Columns.Add("EmpId", typeof(int));
dt2.Columns.Add("DeptId", typeof(int));
dt2.Columns.Add("FullName", typeof(string));
dt2.Columns.Add("DepartmentName", typeof(string));
dt2.Constraints.Add("PkEmployee", dt2.Columns["EmpId"], true);
ds.Relations.Add(dt1.Columns["DeptId"], dt2.Columns["DeptId"]);
dt2.Columns["DepartmentName"].Expression = "Parent.Description";
dt1.Rows.Add(1, "Finance");
dt1.Rows.Add(2, "IT");
dt2.Rows.Add(1, 2, "Baavgai");
System.Diagnostics.Debug.WriteLine(ds.GetXml());
Results:
<NewDataSet>
<Deparment>
<DeptId>1</DeptId>
<Description>Finance</Description>
</Deparment>
<Deparment>
<DeptId>2</DeptId>
<Description>IT</Description>
</Deparment>
<Employee>
<EmpId>1</EmpId>
<DeptId>2</DeptId>
<FullName>Baavgai</FullName>
<DepartmentName>IT</DepartmentName>
</Employee>
</NewDataSet>
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|