Click here to Skip to main content
16,020,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I have to populate a GridView from a Table in Database. I was populating it by following query (which was ok).

SQL
SELECT * FROM EmailTable WHERE empno IN(Select EmpNo from RetiredEmployees) AND disable IS NULL AND deleted IS NULL.


Now my boss said that you are supposed to make a WebService of RetiredEmployees which will return an Array of RetiredEmployees.

So I made it accordingly, now the problem is how I cross match EmpNo in ArrayList in SQL statement.

SQL
SELECT * FROM EmailTable WHERE empno IN(Select EmpNo from RetiredEmployees(Service ArrayList)) AND disable IS NULL AND deleted IS NULL.



thanks in advance
Posted
Comments
ZurdoDev 7-Aug-12 8:24am    
SQL can't handle the arrays, as far as I know. You'll have to do some code to convert the array into a string so that you end up with something like "SELECT EmpNo from RetiredEmployees WHERE EmpNo IN ('Employee1','Employee2','etc'))

thanks for replying Andrew

I resolved it myself with an easy way. I converted array values into CSV, which generated a long messy string. I put that string object into SQL, it seems working fine but any other idea will be appreciated.

thanks again,
 
Share this answer
 
You have a couple of options, see here[^].

I personally favor using XML, but you'd wand to find the best solution that fits your situation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900