PC Review


Reply
Thread Tools Rate Thread

DataSet.Merge with Column.Expression. expression not

 
 
=?Utf-8?B?R2llZHJpdXM=?=
Guest
Posts: n/a
 
      10th Jan 2005
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?
 
Reply With Quote
 
 
 
 
Sahil Malik
Guest
Posts: n/a
 
      10th Jan 2005
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" <(E-Mail Removed)> wrote in message
news2B1FB16-53FF-4635-B0DF-(E-Mail Removed)...
> 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?



 
Reply With Quote
 
=?Utf-8?B?R2llZHJpdXM=?=
Guest
Posts: n/a
 
      11th Jan 2005
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" wrote:

> 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" <(E-Mail Removed)> wrote in message
> news2B1FB16-53FF-4635-B0DF-(E-Mail Removed)...
> > 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?

>
>
>

 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      11th Jan 2005
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" <(E-Mail Removed)> wrote in message
news:E5EBFDB0-C4AF-4016-B076-(E-Mail Removed)...
> 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" wrote:
>
> > 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" <(E-Mail Removed)> wrote in message
> > news2B1FB16-53FF-4635-B0DF-(E-Mail Removed)...
> > > 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?

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?R2llZHJpdXM=?=
Guest
Posts: n/a
 
      12th Jan 2005
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" wrote:

> 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" <(E-Mail Removed)> wrote in message
> news:E5EBFDB0-C4AF-4016-B076-(E-Mail Removed)...
> > 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" wrote:
> >
> > > 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" <(E-Mail Removed)> wrote in message
> > > news2B1FB16-53FF-4635-B0DF-(E-Mail Removed)...
> > > > 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?
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
after dataset.merge(..) datacolumn.expression is not working? Giedrius Microsoft ADO .NET 1 12th Aug 2005 03:41 PM
DataSet.Merge and Column.Expression tomb Microsoft ADO .NET 3 20th May 2005 01:00 AM
dataset column expression Gary Microsoft ADO .NET 4 17th Oct 2003 11:40 AM
Expression DataColumns don't get evaluated after a DataSet Merge() Germán Microsoft ADO .NET 0 30th Sep 2003 01:44 PM
DataSet Merge & Expression Fields Laura Villa Microsoft ADO .NET 0 1st Sep 2003 04:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:00 AM.