How should I search for an int value in a table? Actually my sql query works for string values but not for numbers.
SELECT * FROM [Book] WHERE ([bookId] = @bookId)
I’m using vs and get values from text boxes.Insert query in gridview.
bookId is an autogenerated INT value.
This question is very hard to answer unless you provide us with some more information. Useful information in this case is the table schema or CREATE statement of your Book table, consisting of a list of the attributes (or columns) in the table and their data type. It would also help to know what Database Management System (DBMS) you’re using, like MySQL, PostgreSQL, Microsoft SQL Server, Oracle Database etc.
I am assuming that your table can be created by the following CREATE statement:
In this case, assuming (again) that your Book table contains a book with bookId 3 the following query should run without a problem:
If this does not work, I would guess that the data type of your bookId attribute is not INT, but some text type. But again, it is hard to help you with only the data that you have provided so far.