0

When I placed the the following SQL query,

SELECT
   [ItemID], [Name], [RelDate], [Price], [Status] 
FROM 
   [item_k] 
WHERE 
   [ItemID] IN (" + itemIDs + ")

in gridview custom sql statements, it gets transformed to,

SELECT 
   ItemID, Name, RelDate, Price, Status   
FROM 
   item_k 
WHERE 
   (ItemID IN ([ + itemIDs + ]))

and when I execute the query the following error is shown

SQL Execution Error
Invalid column name '+ itemIDs+'

what seems to be the problem?

thanks

3 Answers 3

1

Have you tried putting + itemIDs+ in single quotes?

Sign up to request clarification or add additional context in comments.

Comments

1

The problem with your string concat method is that it would possibly leave you vulnerable to SQL injection. I wouldn't try to fix this approach, but go for a a parameterized query that doesn't require string concatenation.

Comments

0
SELECT [ItemID], [Name], [RelDate], [Price], [Status] FROM [item_k] WHERE [ItemID] IN (' + itemIDs + ')

changed " to ' and it worked!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.