IN clause issues with data adapters/SQL Server?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greetings all -

I'm trying to build a parameter set that would be passed into an IN clause in my data adapter that reads into SQL Server. The problem I'm experiencing is that when I've selected more than 1 item from the listbox, it doesn't return any records when I know it should. I'm guessing that SQL Server can't interpret my multiple values but with this being such a common function in the software development world, how can this be accomplished if SQL Server doesn't interpret the string of values the way I want. Has anybody discovered a solution that could work

Much thanks to all who have read this

Robert Jenkins
 
Hi Robert,

You'll have to build Sql statement by yourself.
You can't define a paremeter that holds IN values.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

Robert said:
Greetings all -

I'm trying to build a parameter set that would be passed into an IN clause
in my data adapter that reads into SQL Server. The problem I'm experiencing
is that when I've selected more than 1 item from the listbox, it doesn't
return any records when I know it should. I'm guessing that SQL Server
can't interpret my multiple values but with this being such a common
function in the software development world, how can this be accomplished if
SQL Server doesn't interpret the string of values the way I want. Has
anybody discovered a solution that could work?
 
Miha -

Do you mean that if I build a concatenated string using "OR" based on the items selected that if passed in as a string variable, it could work? Since I haven't done it that way before, I wanted to be clear

Thanks -

Rober

----- Miha Markic wrote: ----

Hi Robert

You'll have to build Sql statement by yourself
You can't define a paremeter that holds IN values

--
Miha Markic - RightHand .NET consulting & developmen
miha at rthand co

Robert said:
Greetings all
in my data adapter that reads into SQL Server. The problem I'm experiencin
is that when I've selected more than 1 item from the listbox, it doesn'
return any records when I know it should. I'm guessing that SQL Serve
can't interpret my multiple values but with this being such a commo
function in the software development world, how can this be accomplished i
SQL Server doesn't interpret the string of values the way I want. Ha
anybody discovered a solution that could work
 
Robert said:
Miha -

Do you mean that if I build a concatenated string using "OR" based on the
items selected that if passed in as a string variable, it could work? Since
I haven't done it that way before, I wanted to be clear.

No, you'll have to create whole sql statament.
The other way would be to create a stored procedure that accepts string
variable (with IN value) and creates the whole statament.
There is no other way I see.
 
Back
Top