Newbie needs jump start

  • Thread starter Thread starter Donna
  • Start date Start date
D

Donna

Hi,

I am looking for information on efficient use of ADO .Net.
I am totally new to this world (Unix/C++ background) and am looking for
rules-of-thumb regarding some basic concepts (note this is for WinForms app
in C#) -

1) use and reuse of components. datasets - when to hold more tables in fewer
datasets vs the reverse. dataadapters - when to reuse and when to use many

2) connections - when it might make sense to keep a connection open vs
frequent opening/closing of connections.

3) fetching data - always just when needed or are there circumstances in
which it would be better to load up front
(in my case, datareader subset of records and columns used in a "master
search datagrid")

4) from my research so far, it seems that I should use datareaders where
possible, and that dataviews are the correct way to control which columns
display in grid. Is this correct?

These are my getting-started questions which I can't seem to find
straightforward answers to...maybe there aren't any, but thanks in advance
for any help. I haven't even really gotten into thinking about concurrency
yet, but any pointers on that are appreciated also (as well as anything else
I am too naive to even think of).

Cheers,
Donna
 
Hi Donna,
I'll try to help out as best I can, since I was new to .NET about 7
months ago. I did however come from an ADO background.

(I'll comment to each of your enumerations)

#1. No real dos/don't as far as I know. I would suggest not holding lots of
tables in a dataset if you won't use them more than once. I have several
apps and I have a class that handles all my datasource specific code, which
returns resultsets in primarily DataTables, which are short lived and
discarded. I do have one app that has 7 datasets, one of which has about 10
tables in it that have parent/child relationsips. It seemed natural that
these should all live together in the same dataset. I have seen no great
reasons to do things other than the way I have so far.

#2 So far as I know, just use the standard practice: connection
opening/closing is relatively slow so if you need speed (usually) then open
one and share it. .NET has connection pooling built-in, and if you create 2
connections in the same app (via 2 connection objects) with the same connect
string it "sees" this and just shares the same connection between objects.

#3 Again, discretionary. I think it really depends on the implementation.

#4 I think so. I tend to use DataTables because I like the syntax of
accessing data in there (DataTable.Rows[x][y]). I tend to use DataReaders
when I want one row of data only, in a read-only, read-once kind of fashion.
Not that this is "the" way, just what seems convenient to me.

I bought the "Beginning C# Databases" book (WROX Press) and found it to have
some usefult nuggets of info, but generally a bit too abriged. I'd love to
have an analog of the Vieira book (SQL Server 2000 Programming) on the
subject of ado.NET. Please pass along the info if you discover one :)

Tyson
 
Back
Top