this might seem like a weird question, earlier I posted another question on ASP multiple values through a session variable, I've now figured that out and have managed to pass all three values for instance to a label. Now however I need to pass the three IDs to create a gridview for the three values... So for my SQL statement I have:
SelectCommand="SELECT [BookID], [book_t开发者_运维技巧itle] FROM [tblBook] WHERE ([BookID] = ?)">
So I need there to be 3 BookID=?,?,? for instance, is this possible?
Or is there another way to do it in ASP?
i think what you're looking for is something like this:
SELECT [BookID], [book_title] FROM [tblBook] WHERE [BookID] in (?,?,?)
In SQL, you can use the 'IN' operator to do it. The SQL query would be
SELECT [BookID], [book_title] FROM [tblBook] WHERE [BookID] IN (@Book1,@Book2,@Book3)
You will have to pass the book1,2,3 as parameters to the asp function. You might have to construct the query dynamically by appending the parameters. Something like this
string query = string.Format("SELECT [BookID], [book_title] FROM [tblBook] WHERE [BookID] IN ({0},{1},{2})",book1,book2,book3)
I'm not certain by your question, but I think you're after an IN
statement
SelectCommand="SELECT [BookID], [book_title] FROM [tblBook] WHERE ([BookID] in (1,2,3)">
精彩评论