Limiting the Number of results retrived using ODBC on MS access DB by C# [modified]
-
Hi ;) im trying to Limit the number of results retrived by a Query so for Example i want to retrive the first 30 and then navigate throw the results 30 by 30. the problem in my Query that i cant used the
TOP
30 command because im Ordering my results with date then status plus alot of ordering. and this ordering will cause the retrived results to be retrived in a random ID_no order as one of my friends suggested that i use the TOP 30 along with Where Id no > X Order BY Id_no as in the example below. but i think if there is no Command in MS Access or that i dont know it because of my lack of knowledge i will have to order by my Where Criteria along with the TOP 30 command. Another Sol. just popped to my head is to save the results to a Dataset and then using a Table in the Dataset i can just retrived Index based. i guess i will try the Dataset sollution also if there is any better one plz Help. By the way im using ODBC COnnection, OdbcCommand and ODBCDatareader. Thanks in Advance. Example for Retriving by the TOP and Where command: 1)Select TOP 30 A.ID_no , .......etc From A , ......etc Where A.ID_no > 1 Order by ID_no ;
2)Select TOP 30 A.ID_no , .......etc From A , ......etc Where A.ID_no > 30 Order by ID_no ;
and i continue like that. ---------------------------------- Have fun and Stay good -- modified at 4:14 Saturday 25th November, 2006 -
Hi ;) im trying to Limit the number of results retrived by a Query so for Example i want to retrive the first 30 and then navigate throw the results 30 by 30. the problem in my Query that i cant used the
TOP
30 command because im Ordering my results with date then status plus alot of ordering. and this ordering will cause the retrived results to be retrived in a random ID_no order as one of my friends suggested that i use the TOP 30 along with Where Id no > X Order BY Id_no as in the example below. but i think if there is no Command in MS Access or that i dont know it because of my lack of knowledge i will have to order by my Where Criteria along with the TOP 30 command. Another Sol. just popped to my head is to save the results to a Dataset and then using a Table in the Dataset i can just retrived Index based. i guess i will try the Dataset sollution also if there is any better one plz Help. By the way im using ODBC COnnection, OdbcCommand and ODBCDatareader. Thanks in Advance. Example for Retriving by the TOP and Where command: 1)Select TOP 30 A.ID_no , .......etc From A , ......etc Where A.ID_no > 1 Order by ID_no ;
2)Select TOP 30 A.ID_no , .......etc From A , ......etc Where A.ID_no > 30 Order by ID_no ;
and i continue like that. ---------------------------------- Have fun and Stay good -- modified at 4:14 Saturday 25th November, 2006Can you please clarify what is your criteria of retriving the TOP 30 records? Is it that, you want top 30 records as they appear in the table in the order of you primary key column? Is A>ID_no your primary key column? Can you please try the following and let me know: - SELECT A.ID_no , .......etc From A , ......etc Where 30>=(SELECT COUNT(*) FROM A a WHERE A.ID_no>=a.ID_no) Order by ID_no,........etc