Access to tables in dataset

  • Thread starter Thread starter DesCF
  • Start date Start date
D

DesCF

Is it possible to treat the tables in the dataset the same as any other
tables, i.e. run queries on them, etc. ?
 
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)
 
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)
-----------------------------------------------------------------------------------------------------------------------
 
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
 
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)
-----------------------------------------------------------------------------------------------------------------------


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
 
Back
Top