Re: TableAdapter vs. DataAdapter: Ad Hoc Queries



Bill,

There was my answer based on.

:-)

Cor

"William Vaughn (MVP)" <billva@xxxxxxxxxxxxxxx> schreef in bericht news:eAsRhqW%23IHA.4320@xxxxxxxxxxxxxxxxxxxxxxx
Cor, one cannot pass anything except WHERE-clause constraints to a SP or arguments to operators that accept them (like TOP). The list of columns and the list of tables in a SELECT cannot be passed as parameters unless the query is generated on the fly as a string and this is not recommended as it leads to SQL injection attacks. This is how TSQL works.

--
__________________________________________________________________________
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)
____________________________________________________________________________________________



"Cor Ligthert[MVP]" <notmyfirstname@xxxxxxxxx> wrote in message news:3E70B1D5-CBC4-4B88-A0E9-4AA650EB069E@xxxxxxxxxxxxxxxx
Hi Bill,

How does this one go or on what page have you describen this on your book.

Select @pA from @pB Where @pC @pD @pE

@pA = *
@pB = Whatever
@pC = DateNow
@pD = >
@pE = "2-4=2047"

I am curious because although I use a lot of Linq now am I curious because I was never able to do this

Cor


"William Vaughn (MVP)" <billva@xxxxxxxxxxxxxxx> schreef in bericht news:D5459907-1D3D-4B4A-8726-113665154073@xxxxxxxxxxxxxxxx
First, I suggest you enter your name (even a pseudonym) instead of "msnews.microsoft.com".
It is entirely possible (and a recommended practice) to construct either parameter-driven stored procedures or parameter-driven ad hoc queries to populate the TableAdapter rowsets. I've written a few articles on this for SQL Server magazine as well as for Developer.Com http://www.developer.com/db/article.php/10920_3693236_1 that can walk you through the process. Look for the section of the article that shows how to add new TableAdapter queries.

Of course, I discuss this in depth in my book.

--
__________________________________________________________________________
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)
____________________________________________________________________________________________



"msnews.microsoft.com" <nie.msft@xxxxxxxxxxx> wrote in message news:uGs1r0D#IHA.1016@xxxxxxxxxxxxxxxxxxxxxxx
Dear group,

Am I right in my understanding that when using strongly typed table adapters I am limited to the (select) statements defined in the various .FillBy... and .GetDataBy... functions?

I'd like to build a flexible select statement on a table based on a filter set by the user. He should be able to restrict the data by setting the conditions on different table columns (WHERE clause), where the filter can be any comparison operator like =, <, <=, etc, or a predicate like BETWEEN, LIKE, etc.

As I understand, a select statement built this way can not be passed to a strongly typed table adapter.

Many thanks for your suggestions,
Etienne



.



Relevant Pages


Loading