Home All Groups Group Topic Archive Search About

paramertised select query

Author
4 Sep 2006 10:56 AM
steve
Hi All

A lot of comments in replies to my posts in these newsgroups encourage me to
use parametised queries to protect against injection attacks

How can I return a datatable from a function by passing the function a
sqlclient command object

The command object only has executenonquery method or executereader and I
need a datatable with the result set

I am using vb.net 2005 and sql server express 2005 in a windows form
application

Regards
Steve

Author
4 Sep 2006 3:39 PM
Kerry Moorman
Steve,

You could assign the command object to a dataadapter's SelectCommand
property, call the dataadapter's Fill method, sending it a datatable to be
filled, and return the filled datatable.

Kerry Moorman


Show quoteHide quote
"steve" wrote:

> Hi All
>
> A lot of comments in replies to my posts in these newsgroups encourage me to
> use parametised queries to protect against injection attacks
>
> How can I return a datatable from a function by passing the function a
> sqlclient command object
>
> The command object only has executenonquery method or executereader and I
> need a datatable with the result set
>
> I am using vb.net 2005 and sql server express 2005 in a windows form
> application
>
> Regards
> Steve
>
>
>
Author
4 Sep 2006 8:56 PM
steve
Hi Kerry

Thanks so much

Worked a treat

Regards
Steve


Show quoteHide quote
"Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
news:79426A2A-FD23-4917-B1A3-A669C258ECAD@microsoft.com...
> Steve,
>
> You could assign the command object to a dataadapter's SelectCommand
> property, call the dataadapter's Fill method, sending it a datatable to be
> filled, and return the filled datatable.
>
> Kerry Moorman
>
>
> "steve" wrote:
>
>> Hi All
>>
>> A lot of comments in replies to my posts in these newsgroups encourage me
>> to
>> use parametised queries to protect against injection attacks
>>
>> How can I return a datatable from a function by passing the function a
>> sqlclient command object
>>
>> The command object only has executenonquery method or executereader and I
>> need a datatable with the result set
>>
>> I am using vb.net 2005 and sql server express 2005 in a windows form
>> application
>>
>> Regards
>> Steve
>>
>>
>>