Groups | Blog | Home
all groups > dotnet ado.net > july 2007 >

dotnet ado.net : Access to tables in dataset


William (Bill) Vaughn
7/11/2007 8:54:52 AM
Sure.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

[quoted text, click to view]

William (Bill) Vaughn
7/11/2007 11:30:49 AM
I assumed you meant that you wanted to treat the "tables" in the DataSet
(which are DataTable objects) like independent DataTables. You can.

AFA DataTable objects (which should have been called Rowset objects) cannot
be "selected" against as ADO.NET does not YET have a query engine. That's
coming in Orcas. So, no, you can't do JOINs against the tables but you can
sort, find, filter and massage the DataTable objects in a DataSet.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

[quoted text, click to view]

DesCF
7/11/2007 1:17:27 PM
Is it possible to treat the tables in the dataset the same as any other
tables, i.e. run queries on them, etc. ?




--
DesCF
7/11/2007 7:03:33 PM
How do you do it then ?


On Wed, 11 Jul 2007 16:54:52 +0100, William (Bill) Vaughn
[quoted text, click to view]




--
William (Bill) Vaughn
7/12/2007 9:53:20 AM
I might approach this a bit differently. How about binding the list of valid
customer IDs (in the DataTable) to a dropdown list in the UI. That way the
user does not enter a number at all but pick from a list of known good
values.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

[quoted text, click to view]
The absence of a query engine is what's making things a bit more difficult
than they need be then? For example I wanted to validate the existence of
a Customer ID entered in a form textbox. At first I was going to run a
query against the source tables, but then I remembered that I already had
a valid list of Customer ID's in the DataSet (used to populate an adjacent
combo box). The difficulty was how to query them for the existence of the
Customer ID. Eventually (after quite some fiddling around) I have settled
on:

CType(Me.NorthwindDataSet.bdl_CustomersByName.Compute("Count(CustomerID)",
"CustomerID = '" & txt.Text.Trim.ToUpper & "'"), Boolean)

Mainly because I get a count of 1 or 0 back which lends itself to a
boolean Yes/No answer. But is this the best way of doing it? I'd rather
do a simple Select statement against the DataTable.


Des



On Wed, 11 Jul 2007 19:30:49 +0100, William (Bill) Vaughn
[quoted text, click to view]



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

DesCF
7/12/2007 2:35:47 PM

The absence of a query engine is what's making things a bit more difficu=
lt =

than they need be then? For example I wanted to validate the existence =
of =

a Customer ID entered in a form textbox. At first I was going to run a =
=

query against the source tables, but then I remembered that I already ha=
d =

a valid list of Customer ID's in the DataSet (used to populate an adjace=
nt =

combo box). The difficulty was how to query them for the existence of t=
he =

Customer ID. Eventually (after quite some fiddling around) I have settl=
ed =

on:

CType(Me.NorthwindDataSet.bdl_CustomersByName.Compute("Count(CustomerID)=
", =

"CustomerID =3D '" & txt.Text.Trim.ToUpper & "'"), Boolean)

Mainly because I get a count of 1 or 0 back which lends itself to a =

boolean Yes/No answer. But is this the best way of doing it? I'd rathe=
r =

do a simple Select statement against the DataTable.


Des



On Wed, 11 Jul 2007 19:30:49 +0100, William (Bill) Vaughn =

[quoted text, click to view]
=

[quoted text, click to view]



-- =

AddThis Social Bookmark Button