Home All Groups Group Topic Archive Search About

Retrieving DataTable results programmatically

Author
26 Dec 2006 6:58 AM
Barry
Hi

I am using DataTable/DataSet in VS 2005, The sql statement is coded in
script, i want to know how to retrteve results by changing the SQL
commandtext progrmmatically

something like this (possibly)
dsSearchOperators.Operator.Select("State='CA'");

or

using the SQL Statement modified internally like this

dsSearchOperators.commandtext = "SELECT * FROM XX where State='CA'";

note 2nd one is fictitious

TIA
Barry

Author
26 Dec 2006 9:17 AM
Rad [Visual C# MVP]
On Tue, 26 Dec 2006 12:28:20 +0530, Barry wrote:

Show quote
> Hi
>
> I am using DataTable/DataSet in VS 2005, The sql statement is coded in
> script, i want to know how to retrteve results by changing the SQL
> commandtext progrmmatically
>
> something like this (possibly)
> dsSearchOperators.Operator.Select("State='CA'");
>
> or
>
> using the SQL Statement modified internally like this
>
> dsSearchOperators.commandtext = "SELECT * FROM XX where State='CA'";
>
> note 2nd one is fictitious
>
> TIA
> Barry

If you want to change the sql statement, that will have to be done at the
data adapter level.

If, however, you want to filter results that have already been returned,
you could use a DataView and set its RowFilter property to filter the data
Author
26 Dec 2006 1:47 PM
Dave Sexton
Hi Barry,

If "State" is the field that will always be checked and the only variable
portion is 'CA' then you can use a parameterized query:

Data Access in Client and Middle-Tier Programming
How to: Create Parameterized TableAdapter Queries
http://msdn2.microsoft.com/en-us/library/ms171905(VS.80).aspx

Data Access in Client and Middle-Tier Programming
How to: Add a Parameterized Query to a Form in a Windows Application
http://msdn2.microsoft.com/en-us/library/aeez5k4f(vs.80).aspx

Show quote
"Barry" <some***@somewheer.com> wrote in message
news:%23rvx8sLKHHA.1248@TK2MSFTNGP02.phx.gbl...
> Hi
>
> I am using DataTable/DataSet in VS 2005, The sql statement is coded in
> script, i want to know how to retrteve results by changing the SQL
> commandtext progrmmatically
>
> something like this (possibly)
> dsSearchOperators.Operator.Select("State='CA'");
>
> or
>
> using the SQL Statement modified internally like this
>
> dsSearchOperators.commandtext = "SELECT * FROM XX where State='CA'";
>
> note 2nd one is fictitious
>
> TIA
> Barry
>

AddThis Social Bookmark Button