Click here to Skip to main content
16,004,647 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the following SQL select command to select some row,
C#
cmd = new SqlCommand("SELECT question FROM examQuestionWritten WHERE tchId = '" + getTchId   + "' and session = '" + getSession + "' and dept = '" + getDept + "' and subject = '" + getSubject + "' and quizNum = '" + getQuizNum  + "' ORDER BY questionNum ASC ", vcon);

It work fine but it fails to select the first element that it should be. Example, if it have 4 row to select, it always ignore 1st row and select the other (2,3 and 4th row). I don't know what is the problem, please help me.
Posted
Comments
Thomas ktg 3-Sep-13 2:16am    
Check the conditions you provide in the where clause matches the first row to be selected if it does not probably it will not return the first row.
Some condition is not matching for that row. Take a closer look, you may see what is the issue.
P_Dash 3-Sep-13 2:22am    
Parameter used in Order By clause should be present in Select statement.
Otherwise it might give you weird values.
OriginalGriff 3-Sep-13 2:54am    
Show us the code that uses that SQL command - I suspect the problem is there, rather than related to the actual SELECT statement.

i think condition is not satisfying.Plz check the code properly.
 
Share this answer
 
Hi,

In your query you are using AND operator for condition. When all condition meets based on this it will retieve data.

Note :
Check for empty space in your values.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900