|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
refreshing datasetsHi,
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 Hi,
Why don't you store your current position (current PK) before doing refresh and after refresh re-set position? -- Show quoteMiha 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" <swo***@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 > 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 -- Show quoteBest 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" <swo***@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 >> > > That's why you have to store the position in grid *before* refill and
re-apply it after refill. -- Show quoteMiha 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" <swo***@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" <swo***@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 >>> >> >> > > 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. -- Show quoteBest 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" <swo***@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" <swo***@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 >>>> >>> >>> >> >> > > 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 -- Show quoteMiha 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" <swo***@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" <swo***@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" <swo***@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 >>>>> >>>> >>>> >>> >>> >> >> > > Miha,
Thanks -- Show quoteBest 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" <swo***@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" <swo***@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" <swo***@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 >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > 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? -- Show quoteBest 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" <swo***@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" <swo***@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" <swo***@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 >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > Mark,
Did you clear the dataset before refilling it again? dataset.clear Cor Show quote "Mark" <swo***@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 > |
|||||||||||||||||||||||