PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET refreshing datasets

Reply

refreshing datasets

 
Thread Tools Rate Thread
Old 23-06-2006, 02:30 PM   #1
Mark
Guest
 
Posts: n/a
Default refreshing datasets


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.

--
Best regards
Mark


  Reply With Quote
Old 23-06-2006, 07:47 PM   #2
Miha Markic [MVP C#]
Guest
 
Posts: n/a
Default Re: refreshing datasets

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" <swozz_@hotmail.com> wrote in message
news:Oxq25JulGHA.1240@TK2MSFTNGP05.phx.gbl...
> 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.
>
> --
> Best regards
> Mark
>



  Reply With Quote
Old 23-06-2006, 09:45 PM   #3
Mark
Guest
 
Posts: n/a
Default Re: refreshing datasets

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
news:O7RbHWvlGHA.4220@TK2MSFTNGP05.phx.gbl...
> 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" <swozz_@hotmail.com> wrote in message
> news:Oxq25JulGHA.1240@TK2MSFTNGP05.phx.gbl...
>> 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.
>>
>> --
>> Best regards
>> Mark
>>

>
>



  Reply With Quote
Old 23-06-2006, 10:04 PM   #4
Miha Markic [MVP C#]
Guest
 
Posts: n/a
Default Re: refreshing datasets

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" <swozz_@hotmail.com> wrote in message
news:egYYnXwlGHA.3576@TK2MSFTNGP04.phx.gbl...
> 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
> news:O7RbHWvlGHA.4220@TK2MSFTNGP05.phx.gbl...
>> 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" <swozz_@hotmail.com> wrote in message
>> news:Oxq25JulGHA.1240@TK2MSFTNGP05.phx.gbl...
>>> 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.
>>>
>>> --
>>> Best regards
>>> Mark
>>>

>>
>>

>
>



  Reply With Quote
Old 24-06-2006, 06:29 AM   #5
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: refreshing datasets

Mark,

Did you clear the dataset before refilling it again?

dataset.clear

Cor

"Mark" <swozz_@hotmail.com> schreef in bericht
news:Oxq25JulGHA.1240@TK2MSFTNGP05.phx.gbl...
> 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.
>
> --
> Best regards
> Mark
>



  Reply With Quote
Old 24-06-2006, 10:27 AM   #6
Mark
Guest
 
Posts: n/a
Default Re: refreshing datasets

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 [MVP C#]" <miha at rthand com> wrote in message
news:%23YnYZiwlGHA.1740@TK2MSFTNGP05.phx.gbl...
> 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" <swozz_@hotmail.com> wrote in message
> news:egYYnXwlGHA.3576@TK2MSFTNGP04.phx.gbl...
>> 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
>> news:O7RbHWvlGHA.4220@TK2MSFTNGP05.phx.gbl...
>>> 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" <swozz_@hotmail.com> wrote in message
>>> news:Oxq25JulGHA.1240@TK2MSFTNGP05.phx.gbl...
>>>> 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.
>>>>
>>>> --
>>>> Best regards
>>>> Mark
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 24-06-2006, 11:05 AM   #7
Miha Markic [MVP C#]
Guest
 
Posts: n/a
Default Re: refreshing datasets

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" <swozz_@hotmail.com> wrote in message
news:OjZMpB3lGHA.4268@TK2MSFTNGP05.phx.gbl...
> 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 [MVP C#]" <miha at rthand com> wrote in message
> news:%23YnYZiwlGHA.1740@TK2MSFTNGP05.phx.gbl...
>> 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" <swozz_@hotmail.com> wrote in message
>> news:egYYnXwlGHA.3576@TK2MSFTNGP04.phx.gbl...
>>> 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
>>> news:O7RbHWvlGHA.4220@TK2MSFTNGP05.phx.gbl...
>>>> 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" <swozz_@hotmail.com> wrote in message
>>>> news:Oxq25JulGHA.1240@TK2MSFTNGP05.phx.gbl...
>>>>> 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.
>>>>>
>>>>> --
>>>>> Best regards
>>>>> Mark
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 24-06-2006, 11:42 AM   #8
Mark
Guest
 
Posts: n/a
Default Re: refreshing datasets

Miha,

Thanks

--
Best regards
Mark

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:u1u7oc3lGHA.4808@TK2MSFTNGP05.phx.gbl...
> 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" <swozz_@hotmail.com> wrote in message
> news:OjZMpB3lGHA.4268@TK2MSFTNGP05.phx.gbl...
>> 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 [MVP C#]" <miha at rthand com> wrote in message
>> news:%23YnYZiwlGHA.1740@TK2MSFTNGP05.phx.gbl...
>>> 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" <swozz_@hotmail.com> wrote in message
>>> news:egYYnXwlGHA.3576@TK2MSFTNGP04.phx.gbl...
>>>> 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
>>>> news:O7RbHWvlGHA.4220@TK2MSFTNGP05.phx.gbl...
>>>>> 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" <swozz_@hotmail.com> wrote in message
>>>>> news:Oxq25JulGHA.1240@TK2MSFTNGP05.phx.gbl...
>>>>>> 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.
>>>>>>
>>>>>> --
>>>>>> Best regards
>>>>>> Mark
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 28-06-2006, 09:38 AM   #9
Mark
Guest
 
Posts: n/a
Default Re: refreshing datasets

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 [MVP C#]" <miha at rthand com> wrote in message
news:u1u7oc3lGHA.4808@TK2MSFTNGP05.phx.gbl...
> 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" <swozz_@hotmail.com> wrote in message
> news:OjZMpB3lGHA.4268@TK2MSFTNGP05.phx.gbl...
>> 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 [MVP C#]" <miha at rthand com> wrote in message
>> news:%23YnYZiwlGHA.1740@TK2MSFTNGP05.phx.gbl...
>>> 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" <swozz_@hotmail.com> wrote in message
>>> news:egYYnXwlGHA.3576@TK2MSFTNGP04.phx.gbl...
>>>> 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
>>>> news:O7RbHWvlGHA.4220@TK2MSFTNGP05.phx.gbl...
>>>>> 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" <swozz_@hotmail.com> wrote in message
>>>>> news:Oxq25JulGHA.1240@TK2MSFTNGP05.phx.gbl...
>>>>>> 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.
>>>>>>
>>>>>> --
>>>>>> Best regards
>>>>>> Mark
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off