Querying Datasets

  • Thread starter Thread starter Leonard Danao
  • Start date Start date
L

Leonard Danao

-- Sorry for teh cross post ---

Good day all, Quick question about Datasets
If someone can point me to a site/manual/etc where i can get the following
information i will be very greatful

My program grabs a set of data from SQL and fills a dataset,
First i want to grab the distinct Customers from this dataset
Then using that I want to build subqueries from the distinct Customers to
get the other necessarry information from the same dataset

SAMPLE CODE
PartsData = GetSQLData(sqlquery) ' takes the sqlquery and returns a dataset
DistinctCustomers = PartsData.Tables(0).Select("DISTINCT CustomerID")

The error i get is "Additional information: Syntax error: Missing operand
after 'DISTINCT' operator."

Where can i find the proper syntaxt for a dataset.tables.select and is
DISTINCT possible on a subquery of a dataset?
I would rather use the disconnected dataset than create multiple trips to
the DB if possible, but if i have to, I have to...(which I am currently
doing)


Thanks to all that respond
Also if you can CC my email address LDANAO[SPAM BLOCKER]@itsllc.com i would
be greatful, delete the SPAM BLOCKER block
 
The "Select" method in ADO.NET works more like a WHERE clause than a SELECT.
It won't recognize DISTINCT.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
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.
__________________________________
 
Hi Leonard,

Leonard Danao said:
-- Sorry for teh cross post ---

Good day all, Quick question about Datasets
If someone can point me to a site/manual/etc where i can get the following
information i will be very greatful

My program grabs a set of data from SQL and fills a dataset,
First i want to grab the distinct Customers from this dataset
Then using that I want to build subqueries from the distinct Customers to
get the other necessarry information from the same dataset

SAMPLE CODE
PartsData = GetSQLData(sqlquery) ' takes the sqlquery and returns a
dataset
DistinctCustomers = PartsData.Tables(0).Select("DISTINCT CustomerID")

The error i get is "Additional information: Syntax error: Missing operand
after 'DISTINCT' operator."

Where can i find the proper syntaxt for a dataset.tables.select and is
DISTINCT possible on a subquery of a dataset?
I would rather use the disconnected dataset than create multiple trips to
the DB if possible, but if i have to, I have to...(which I am currently
doing)

Distinct is not supported on the datatable. Instead you should manually loop
through all rows.
Not a big deal IMO
 
Or better yet, write a DISTINCT query to return distinct values in the first
place.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
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.
__________________________________
 
Thanks for the responses i was hoping that it would act like a SQL table
with SQL Syntax. But i guess i'll have to do it the way i had alraedy
started with, thanks
Len


Miha Markic said:
Ha, certainly, yes. But I guess he needs all the records.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

William (Bill) Vaughn said:
Or better yet, write a DISTINCT query to return distinct values in the
first place.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
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.
__________________________________
 
Back
Top