Adding additional SELECTs to dataadapter

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I need to add additional SELECT commands to dataadapter that take various
filter and order by parameters. How do I add these additional commands to
the dataadapter?

Thanks

Regards
 
John,

At least I can not imagen any thing you mean by your problem.

Can you show us the Transactcode

Cor
 
The (obsolete) DataAdapter can only accept on SelectCommand. While that
Command can contain several SELECT statements and these can have multiple
Parameters, it returns one resultset and generates one DataTable for each
rowset returned.

I expect what you need is a TableAdapter. This class can have several Fill
methods that can be programmed to return a rowset/DataTable given different
SELECT statements (as long as the same columns are returned) and different
Parameters.

--
__________________________________________________________________________
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 http://betav.com/blog/billva
____________________________________________________________________________________________
 
You are correct TableAdapter. How do I add additional sql to it such as
FillByFieldA, FillByFieldAandFieldB etc.

Thanks

Regards
 
Open the DataSet in the designer and right click on the table in question.
you can then choose to add a new command. Add each command you desire, one
by one, and you are done.

While this is not a precise answer to your question, there is a step-by-step
for creating new queries in this blog entry:
http://gregorybeamer.spaces.live.com/Blog/cns!B036196EAF9B34A8!974.entry

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
 
Hi Gregory

I need to do this at runtime as there are two many options to add at design
time.

Thanks

Regards
 
Ah, no. The TableAdapter is a strongly typed class that's constructed by
Visual Studio code generators at design time.
I suggest building one or more Command objects at runtime. They can be
configured with any SELECT statement(s) you need and the DataReader created
by the Command ExecuteReader method can be used to build an untyped
DataTable.

I discuss this in my book at length...

--
__________________________________________________________________________
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 http://betav.com/blog/billva
____________________________________________________________________________________________
 
In addition to Bill, you could create SqlCommand instance as well, a
DbDataAdapter instance (one for your database), attach SqlCommand instance
to DbDataAdapter.SelectCommand and use that DbDataAdapter instance to
retrieve data.
 
Back
Top