DataSet.Merge with Column.Expression. expression not

G

Guest

Hi,
I have ResultDataSet returned by some "DataAccess" component, and I have
typed dataset, with all other functionality.

In typed dataset where are tables with columns which uses expression
ISNULL([Column_A], [Column_B]).
After doing:
myWorkDataSet.Merge(ResultDataSet)
myDataGrid.SetDataBindings(myWorkDataSet, memberTable)
these expressions are not working initially. But after editing any row in
datagrid (and other 3rd party grid), expressions are working again.

Current solution after myWorkDataSet.Merge(ResultDataSet), to do
Column.Expression = Column.Expression
Maybe I am missing something?
 
S

Sahil Malik

Here is code that works ---

DataTable dt1 = new DataTable("Table1") ;
DataTable dt2 = new DataTable("Table2") ;

dt1.Columns.Add(new DataColumn("A"));
dt1.Columns.Add(new DataColumn("B"));
dt1.Columns[0].DataType = typeof(System.Int32);
dt1.Columns[1].DataType = typeof(System.Int32);
dt1.Columns[1].Expression = "A*2";

dt2.Columns.Add(new DataColumn("A"));
dt2.Columns.Add(new DataColumn("B"));
dt2.Columns[0].DataType = typeof(System.Int32);
dt2.Columns[1].DataType = typeof(System.Int32);

DataRow dr;
dr = dt1.NewRow();
dr[0] = "1";
dt1.Rows.Add(dr);

dr = dt2.NewRow();
dr[0] = "2";
dt2.Rows.Add(dr);

dt1.Merge(dt2);
dt1.WriteXml("C:\\1.xml");


Notice that I am using datatable instead of dataset because datatable in
..NET 2.0 supports merge.
The concepts are the same though, so the above datatables, added to datasets
should work in .NET 1.1.

In other words, there's something funky about your code.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
G

Guest

In my code, structures of Merged tables are a bit different.
Only 2 columns from table 1 are the same as in table 2
20 columns in table 1
5 columns in table 2
Thing that helps for expressions to work for a grid is
Column_Counted.Expression = Column_Counted.Expression

In your example you use WriteXML, perhaps it recalculates expressions, I
don't know.




Sahil Malik said:
Here is code that works ---

DataTable dt1 = new DataTable("Table1") ;
DataTable dt2 = new DataTable("Table2") ;

dt1.Columns.Add(new DataColumn("A"));
dt1.Columns.Add(new DataColumn("B"));
dt1.Columns[0].DataType = typeof(System.Int32);
dt1.Columns[1].DataType = typeof(System.Int32);
dt1.Columns[1].Expression = "A*2";

dt2.Columns.Add(new DataColumn("A"));
dt2.Columns.Add(new DataColumn("B"));
dt2.Columns[0].DataType = typeof(System.Int32);
dt2.Columns[1].DataType = typeof(System.Int32);

DataRow dr;
dr = dt1.NewRow();
dr[0] = "1";
dt1.Rows.Add(dr);

dr = dt2.NewRow();
dr[0] = "2";
dt2.Rows.Add(dr);

dt1.Merge(dt2);
dt1.WriteXml("C:\\1.xml");


Notice that I am using datatable instead of dataset because datatable in
..NET 2.0 supports merge.
The concepts are the same though, so the above datatables, added to datasets
should work in .NET 1.1.

In other words, there's something funky about your code.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



Giedrius said:
Hi,
I have ResultDataSet returned by some "DataAccess" component, and I have
typed dataset, with all other functionality.

In typed dataset where are tables with columns which uses expression
ISNULL([Column_A], [Column_B]).
After doing:
myWorkDataSet.Merge(ResultDataSet)
myDataGrid.SetDataBindings(myWorkDataSet, memberTable)
these expressions are not working initially. But after editing any row in
datagrid (and other 3rd party grid), expressions are working again.

Current solution after myWorkDataSet.Merge(ResultDataSet), to do
Column.Expression = Column.Expression
Maybe I am missing something?
 
S

Sahil Malik

No !! ..WriteXML's only purpose in my code is to see what was in the
datatable.
Can you check and see maybe if the dataset actually holds the right data,
but the datagrid isn't reflecting that?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik

Giedrius said:
In my code, structures of Merged tables are a bit different.
Only 2 columns from table 1 are the same as in table 2
20 columns in table 1
5 columns in table 2
Thing that helps for expressions to work for a grid is
Column_Counted.Expression = Column_Counted.Expression

In your example you use WriteXML, perhaps it recalculates expressions, I
don't know.




Sahil Malik said:
Here is code that works ---

DataTable dt1 = new DataTable("Table1") ;
DataTable dt2 = new DataTable("Table2") ;

dt1.Columns.Add(new DataColumn("A"));
dt1.Columns.Add(new DataColumn("B"));
dt1.Columns[0].DataType = typeof(System.Int32);
dt1.Columns[1].DataType = typeof(System.Int32);
dt1.Columns[1].Expression = "A*2";

dt2.Columns.Add(new DataColumn("A"));
dt2.Columns.Add(new DataColumn("B"));
dt2.Columns[0].DataType = typeof(System.Int32);
dt2.Columns[1].DataType = typeof(System.Int32);

DataRow dr;
dr = dt1.NewRow();
dr[0] = "1";
dt1.Rows.Add(dr);

dr = dt2.NewRow();
dr[0] = "2";
dt2.Rows.Add(dr);

dt1.Merge(dt2);
dt1.WriteXml("C:\\1.xml");


Notice that I am using datatable instead of dataset because datatable in
..NET 2.0 supports merge.
The concepts are the same though, so the above datatables, added to datasets
should work in .NET 1.1.

In other words, there's something funky about your code.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



Giedrius said:
Hi,
I have ResultDataSet returned by some "DataAccess" component, and I have
typed dataset, with all other functionality.

In typed dataset where are tables with columns which uses expression
ISNULL([Column_A], [Column_B]).
After doing:
myWorkDataSet.Merge(ResultDataSet)
myDataGrid.SetDataBindings(myWorkDataSet, memberTable)
these expressions are not working initially. But after editing any row in
datagrid (and other 3rd party grid), expressions are working again.

Current solution after myWorkDataSet.Merge(ResultDataSet), to do
Column.Expression = Column.Expression
Maybe I am missing something?
 
G

Guest

Here is my code fragment I used.
No grid is used here, just testing IsCaptionNull.
without resetting Expression, expression column is not evaluated.


Private Sub LoadColumns(ByVal TableId As Integer)
Dim rez As DataSet
rez = Me.Connection.GetData(ColumnParameters(TableId))

Me.Data = New QueryDB
Me.Data.Merge(rez.Tables(0), False, MissingSchemaAction.Ignore)

'=======MESSAGEBOX show expression, and always shows True
Dim c As QueryDB.D_ColumnsRow
MsgBox(Me.Data.D_Columns.CaptionColumn.Expression)
For Each c In Me.Data.D_Columns
MsgBox(c.IsCaptionNull) 'Caption.Expression = ISNULL([Column_A],
[Column_B])
Next

'=======ADDING BELOW CODE WORKS OK==========
Me.Data.D_Columns.CaptionColumn.Expression =
Me.Data.D_Columns.CaptionColumn.Expression

For Each c In Me.Data.D_Columns
MsgBox(c.IsCaptionNull)
Next

..................

Sahil Malik said:
No !! ..WriteXML's only purpose in my code is to see what was in the
datatable.
Can you check and see maybe if the dataset actually holds the right data,
but the datagrid isn't reflecting that?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik

Giedrius said:
In my code, structures of Merged tables are a bit different.
Only 2 columns from table 1 are the same as in table 2
20 columns in table 1
5 columns in table 2
Thing that helps for expressions to work for a grid is
Column_Counted.Expression = Column_Counted.Expression

In your example you use WriteXML, perhaps it recalculates expressions, I
don't know.




Sahil Malik said:
Here is code that works ---

DataTable dt1 = new DataTable("Table1") ;
DataTable dt2 = new DataTable("Table2") ;

dt1.Columns.Add(new DataColumn("A"));
dt1.Columns.Add(new DataColumn("B"));
dt1.Columns[0].DataType = typeof(System.Int32);
dt1.Columns[1].DataType = typeof(System.Int32);
dt1.Columns[1].Expression = "A*2";

dt2.Columns.Add(new DataColumn("A"));
dt2.Columns.Add(new DataColumn("B"));
dt2.Columns[0].DataType = typeof(System.Int32);
dt2.Columns[1].DataType = typeof(System.Int32);

DataRow dr;
dr = dt1.NewRow();
dr[0] = "1";
dt1.Rows.Add(dr);

dr = dt2.NewRow();
dr[0] = "2";
dt2.Rows.Add(dr);

dt1.Merge(dt2);
dt1.WriteXml("C:\\1.xml");


Notice that I am using datatable instead of dataset because datatable in
..NET 2.0 supports merge.
The concepts are the same though, so the above datatables, added to datasets
should work in .NET 1.1.

In other words, there's something funky about your code.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



Hi,
I have ResultDataSet returned by some "DataAccess" component, and I have
typed dataset, with all other functionality.

In typed dataset where are tables with columns which uses expression
ISNULL([Column_A], [Column_B]).
After doing:
myWorkDataSet.Merge(ResultDataSet)
myDataGrid.SetDataBindings(myWorkDataSet, memberTable)
these expressions are not working initially. But after editing any row in
datagrid (and other 3rd party grid), expressions are working again.

Current solution after myWorkDataSet.Merge(ResultDataSet), to do
Column.Expression = Column.Expression
Maybe I am missing something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top