I have a list of id. Those are answer id. I hold as a list in the application. I just want to make request to SQL Server to get answers which matches the id's.
Do I need to use foreach loop in C#? How can I merge result in datatable or something? I need some help about this.
I want to get data with C# in an ASP.NET project.
List of id: <List>
:
answer_id
---------
5
4
23
2
45
16
I want to get with C# and display in datatable: (expected result)
answer_id answer
-------------------------------------
5 It's true
4 Maybe next time
23 Man this is crazy
2 Can i help you?
45 Wtf..
16 I can not believe..
Our select query must return the answer if there is a match. In this example let's say we found all the answers.
Simple query for one result:
SELECT answer_id, answer
FROM answers
WHERE answer_id = 5
Result:
answer_id answer
-----------------------
5 It's true