Hello guys,
I am having a weird problem. I cant understand and i have spent almost 2 hours in finding the problem.
Well,Actually I have a table of id,date,comment.
id and date are composite primary key. so id always starts with 1 everyday.
now i want to find the max id where date = particular.
I am writing this Sql Query for this
"Select MAX(Acc_id) from AccDtl where Acc_Date='" & Me.DTPCollDate.Text & "' and CabRego='" & Me.cmbcabs.Text & "'"
Now this query gives error that index out of range exception. Even when there is 1 record and its ID is 1. it should return 1.
when i use same query without max. like
"Select Acc_id from AccDtl where Acc_Date='" & Me.DTPCollDate.Text & "' and CabRego='" & Me.cmbcabs.Text & "'"
it returns data reader as true until data ends and then it returns false.
where i am wrong and what i can do to correct my mistake.
I thank you in anticipation.