Keeping a DataView in Memory

  • Thread starter Thread starter Fred Block
  • Start date Start date
F

Fred Block

Hi All,

What is the best way to keep a DataView in memory? I need to access it often
(using "Find" to get data from it repeatedly) and then process other data
based on what I pull from it. I'm thinking a class but I'm new to ADO.NET
and OOP (for the most part). I was also thinking this may give better
performance than repeated calls using a stored procedure.

I thought at first module level variables...

Also - Will I need to keep the DataSet and/or DataTable open too used to ?

All thoughts and ideas are greatly appreciated with many thanks in advance!

Kind regards - Fred
 
A DataView is simply a filtered "view" of a DataTable. As long as the
DataTable is not destroyed, it remains in memory.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com/blog/billva
http://betav.com
____________________________________________________________________________________________
 
Hi and thanks!

Being new to this may I ask if I "should" keep the DataSet in memory or is
that not needed after the table is created? I'm not sure of the pecking
order of these objects.

BTW - I own older books if yours and they're "awesome". Are you working on
one for ADO.NET 3.5?

Thanks again!

Kind regards - Fred
 
Of course if you've been reading my books you would know that the impact of
a reasonably-constructed DataSet (of <1000 rows) is small. Yes, it should be
kept in memory if you can use it to avoid more round trips.

And no, I'm not working on an ADO.NET 3.5 book 'cause by the time it was
printed MS will have abandoned 3.5 and moved to more fun stuff for another
18 months (or less). I'm not a fan of LINQ or the EF so it's not likely that
I'll be doing another. The 7th edition took about 30 months to write. I
can't afford to donate that kind of time any more.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com/blog/billva
http://betav.com
____________________________________________________________________________________________
 
Hi William,

Thanks again for the response. I'll make a note of that.

Also - I'll be picking up the book you wrote that's on the market now as I'm
sure it'll be a huge help!

Merry Christmas!

Kind regards - Fred
 
Often ... I don't even use a DataSet.

I define a DataTable().
Fill it with a DataAdapter.
"Index" it with a DataView.

As long as the DataTable and DataView object remain in scope then you can
play with the DataView all you like.
 
Thanks Kenny - I'll give that a shot. I'm still "green" in ADO.NET so I
appreciate any and all input!

Kind regards - Fred
 
And you don't need a DataAdapter either. Open a DataReader, use the new
DataTable.Load method. It's light and fast. Set your DataView properties to
filter or sort as needed.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com/blog/billva
http://betav.com
____________________________________________________________________________________________
 
Hi William,

Thanks a ton for that tip! That did seem to make the data return way faster.
It's easy for me to notice because the data is coming from a remote SQL
connection. With this application on the actual server, I suppose it'll be
light-speed now. I appreciate your time and your input with this topic.

May ask you to recommend one of your two books for me being an ADO.NET
beginner please? ADO.NET and ADO Examples and Best Practices for VB
Programmers, 2nd Edition -or- Hitchhiker's Guide to Visual Studio and SQL
Server (7th Edition)

I'd like both but I'm budgeted for one now...

Thanks! -- Fred
 
Hi Bill,

"I'm not a fan of *LINQ* or the EF so it's not likely that
I'll be doing another. The 7th edition took about 30 months to write. I
can't afford to donate that kind of time any more."

You did mean LINQ to SQL and not LINQ in general, right?
Just checking :-)
BTW, I always wonder where do the writers find all that time required for
writting a book.
 
ADO and ADO.NET Examples and Best Practices is written for developers
transitioning to ADO.NET and has a wealth of fundamental material for those
getting started. The 7th Edition takes up where the ADO.NET E&BP book leaves
off and talks about the ADO.NET that ships with VS 2005 and far more on SQL
Server, the tools and how to design successful applications.

No, I have no idea how authors make money on tech books. They don't stay on
the shelves (being pushed off by more recent content) long enough to pay off
the advances.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com/blog/billva
http://betav.com
____________________________________________________________________________________________
 
Hi William,

I appreciate your reply and will pick up a copy of the ADO and ADO.NET
Examples and Best Practices shortly!

And thanks again for your input on the questions I've had. That code portion
is working well.

Regards - Fred
 
Back
Top