PROBLEM:
How can I get the certain autonumber id?
ID DESCRIPTION CLASS
1 test1 a
2 test2 b
3 test3 a
4 test4 a
5 test5 b
id (auto-increment in SQL Server)
Here is the scenario:
I have here 3 columns something like this.
My class is declared using this to get the value of a certain class.
string strclass = string.empty;
strclass = request.querystring["Class"];
How can I get the id of test2?
I would like to use this select statement wherein I will just use the variable.
For example:
string sqltest = "select description from items where class = '" + strID + "' and class = '" strclass "'";
I just really don’t know, how will I get the class id.
Your question really is very confusing. You want the id but your SQL returns the description. Surely your SQL should just be:
Do not use string concatenation to generate SQL strings as that opens you up to SQL injection attacks.