refreshing datasets

M

Mark

Hi,

I am using VS.NET 2005 with SQL Server 2000.

I have a Dataset that contains a DataTable that is populated using
DataSet.Fill(). I need to periodically refresh this data.

If I just do .Fill() again, I end up with issues of the DataGrid losing it's
current position etc.

Can I utilize a timestamp column in the table and then somehow use
DataSet.GetChanges() and DataSet.Merge()? This way only modified data will
be downloaded from the server minimizing traffic and hopefully the DataGrid
will remember it's position.
 
M

Miha Markic [MVP C#]

Hi,

Why don't you store your current position (current PK) before doing refresh
and after refresh re-set position?
 
M

Mark

Refresh what - the datagrid or dataset? Refreshing the datagrid is no good -
it doesn't get new data from the database, refreshing the dataset can be
done by refilling it but then like I say the datagrid loses it's position

--
Best regards
Mark

Miha Markic said:
Hi,

Why don't you store your current position (current PK) before doing
refresh and after refresh re-set position?
 
M

Miha Markic [MVP C#]

That's why you have to store the position in grid *before* refill and
re-apply it after refill.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Mark said:
Refresh what - the datagrid or dataset? Refreshing the datagrid is no
good - it doesn't get new data from the database, refreshing the dataset
can be done by refilling it but then like I say the datagrid loses it's
position

--
Best regards
Mark

Miha Markic said:
Hi,

Why don't you store your current position (current PK) before doing
refresh and after refresh re-set position?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Mark said:
Hi,

I am using VS.NET 2005 with SQL Server 2000.

I have a Dataset that contains a DataTable that is populated using
DataSet.Fill(). I need to periodically refresh this data.

If I just do .Fill() again, I end up with issues of the DataGrid losing
it's current position etc.

Can I utilize a timestamp column in the table and then somehow use
DataSet.GetChanges() and DataSet.Merge()? This way only modified data
will be downloaded from the server minimizing traffic and hopefully the
DataGrid will remember it's position.
 
C

Cor Ligthert [MVP]

Mark,

Did you clear the dataset before refilling it again?

dataset.clear

Cor
 
M

Mark

How do I do that? I can save and restore the currency managers Position
property but this is no good since the position of the currently highlighted
row can change once new data has been brought into the dataset so doing this
doesn't always rehighlight the same row.

--
Best regards
Mark

Miha Markic said:
That's why you have to store the position in grid *before* refill and
re-apply it after refill.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Mark said:
Refresh what - the datagrid or dataset? Refreshing the datagrid is no
good - it doesn't get new data from the database, refreshing the dataset
can be done by refilling it but then like I say the datagrid loses it's
position

--
Best regards
Mark

Miha Markic said:
Hi,

Why don't you store your current position (current PK) before doing
refresh and after refresh re-set position?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Hi,

I am using VS.NET 2005 with SQL Server 2000.

I have a Dataset that contains a DataTable that is populated using
DataSet.Fill(). I need to periodically refresh this data.

If I just do .Fill() again, I end up with issues of the DataGrid losing
it's current position etc.

Can I utilize a timestamp column in the table and then somehow use
DataSet.GetChanges() and DataSet.Merge()? This way only modified data
will be downloaded from the server minimizing traffic and hopefully the
DataGrid will remember it's position.
 
M

Miha Markic [MVP C#]

Hi Mark,

You have to extract the PK value out of currently positioned record:
CurrencyManager.Current will give you the source object.
Once you refilled the dataset you have to figure out the position of record
with previously retrieved PK value, perhaps by using combination of
DataTable.Rows.Find and DataTable.Rows.IndexOf methods.

HTH
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Mark said:
How do I do that? I can save and restore the currency managers Position
property but this is no good since the position of the currently
highlighted row can change once new data has been brought into the dataset
so doing this doesn't always rehighlight the same row.

--
Best regards
Mark

Miha Markic said:
That's why you have to store the position in grid *before* refill and
re-apply it after refill.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Mark said:
Refresh what - the datagrid or dataset? Refreshing the datagrid is no
good - it doesn't get new data from the database, refreshing the dataset
can be done by refilling it but then like I say the datagrid loses it's
position

--
Best regards
Mark

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi,

Why don't you store your current position (current PK) before doing
refresh and after refresh re-set position?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Hi,

I am using VS.NET 2005 with SQL Server 2000.

I have a Dataset that contains a DataTable that is populated using
DataSet.Fill(). I need to periodically refresh this data.

If I just do .Fill() again, I end up with issues of the DataGrid
losing it's current position etc.

Can I utilize a timestamp column in the table and then somehow use
DataSet.GetChanges() and DataSet.Merge()? This way only modified data
will be downloaded from the server minimizing traffic and hopefully
the DataGrid will remember it's position.
 
M

Mark

Miha,

Thanks

--
Best regards
Mark

Miha Markic said:
Hi Mark,

You have to extract the PK value out of currently positioned record:
CurrencyManager.Current will give you the source object.
Once you refilled the dataset you have to figure out the position of
record with previously retrieved PK value, perhaps by using combination of
DataTable.Rows.Find and DataTable.Rows.IndexOf methods.

HTH
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Mark said:
How do I do that? I can save and restore the currency managers Position
property but this is no good since the position of the currently
highlighted row can change once new data has been brought into the
dataset so doing this doesn't always rehighlight the same row.

--
Best regards
Mark

Miha Markic said:
That's why you have to store the position in grid *before* refill and
re-apply it after refill.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Refresh what - the datagrid or dataset? Refreshing the datagrid is no
good - it doesn't get new data from the database, refreshing the
dataset can be done by refilling it but then like I say the datagrid
loses it's position

--
Best regards
Mark

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi,

Why don't you store your current position (current PK) before doing
refresh and after refresh re-set position?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Hi,

I am using VS.NET 2005 with SQL Server 2000.

I have a Dataset that contains a DataTable that is populated using
DataSet.Fill(). I need to periodically refresh this data.

If I just do .Fill() again, I end up with issues of the DataGrid
losing it's current position etc.

Can I utilize a timestamp column in the table and then somehow use
DataSet.GetChanges() and DataSet.Merge()? This way only modified data
will be downloaded from the server minimizing traffic and hopefully
the DataGrid will remember it's position.
 
M

Mark

Using IndexOf kind of works, but it gives you the position of the row in the
DataTable - if the DataGridView is sorted, then this position is
meaningless - is there a way around this?

--
Best regards
Mark Baldwin

Miha Markic said:
Hi Mark,

You have to extract the PK value out of currently positioned record:
CurrencyManager.Current will give you the source object.
Once you refilled the dataset you have to figure out the position of
record with previously retrieved PK value, perhaps by using combination of
DataTable.Rows.Find and DataTable.Rows.IndexOf methods.

HTH
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Mark said:
How do I do that? I can save and restore the currency managers Position
property but this is no good since the position of the currently
highlighted row can change once new data has been brought into the
dataset so doing this doesn't always rehighlight the same row.

--
Best regards
Mark

Miha Markic said:
That's why you have to store the position in grid *before* refill and
re-apply it after refill.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Refresh what - the datagrid or dataset? Refreshing the datagrid is no
good - it doesn't get new data from the database, refreshing the
dataset can be done by refilling it but then like I say the datagrid
loses it's position

--
Best regards
Mark

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi,

Why don't you store your current position (current PK) before doing
refresh and after refresh re-set position?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Hi,

I am using VS.NET 2005 with SQL Server 2000.

I have a Dataset that contains a DataTable that is populated using
DataSet.Fill(). I need to periodically refresh this data.

If I just do .Fill() again, I end up with issues of the DataGrid
losing it's current position etc.

Can I utilize a timestamp column in the table and then somehow use
DataSet.GetChanges() and DataSet.Merge()? This way only modified data
will be downloaded from the server minimizing traffic and hopefully
the DataGrid will remember it's position.
 

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