Mobile SQL 2005 and limiting data results

  • Thread starter Thread starter ThisBytes5
  • Start date Start date
T

ThisBytes5

I have a table I am using as a QUEUE, some of the data in the table can
be quite large and as such I'd like to pull back only one record at a
time. I've tried

Select top 1 * from Table

and

Set RowCount 1 Set RowCount 1; Set RowCount 1 GO
Select * from Table

None of which seems to work. Is there a way to limit the data being
retreived?

Thanks
Wayne
 
Wayne,

Have you considered using a SqlCeDataReader and counting the rows as you
read them so you can stop when you have the maximum you want?
 
This is actually what I am doing. I had tow threads running, one
writing one reading, they were locking up from time to time and I
thought it may have been a database locking issue. So I wanted to load
the records for reading in a dataset, but not all of them.

Turns out it was a threading issue and I got it resolved. I'd still
like to know if there is a way to limit the rows returned though.

Thanks
Wayne
 
there are a limited set of functions in SQL Mobile (COUNT, MIN, MAX)
and no support for TOP. your best bet is to manage the range of records
either with the SqlCeResultSet as Ginny suggested or think about using
Seek with SetRange and TableDirect mode.

--
Darren Shaffer
..NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com
 
Back
Top