index > SQL Server Everywhere Edition > Getting RecordCount with TableDirect

Getting RecordCount with TableDirect

Hi, I would like to know if there's any method to get the total number of records in a table without using query. I have the following codes.



Dim conn As SqlServerCe.SqlCeConnection
Dim cmd As SqlServerCe.SqlCeCommand
Dim rdr As SqlServerCe.SqlCeDataReader

conn = New SqlServerCe.SqlCeConnection("Data source=\My Documents\test.sdf")
conn.Open()

cmd = New SqlServerCe.SqlCeCommand("Staff_Table", conn)
cmd.CommandType = CommandType.TableDirect
cmd.IndexName = "Id_Ind"

rdr = cmd.ExecuteReader
rdr.Seek(SqlServerCe.DbSeekOptions.FirstEqual, int_seek_n)

If rdr.Read() Then
   strResult = rdr.GetString(1)
End If

rdr.Close()
conn.Close()

 


I did quite a bit of searching and got no results. Thanks.
Drudkh
No, there's no shortcut to getting the count of rows in a table.  I recommend doing a SELECT COUNT(*) and use ExecuteScalar to get the best performance on this query.

-Darren Shaffer



.NET Compact Framework MVP
Darren Shaffer
Thanks Darren. Looks like I have no other choice. :)
Drudkh
reply 3

You can use google to search for other answers

 

More Articles

• Can I use SQL Server Management Studio Express to work with SQL S...
• parameterized query that counts the number of null values in an i...
• Unsupported HTTP function call was made error.
• ISSCEStatusReporting interface - replication progress in C++
• Must you use 3rd party certs for mobile ssl replication?
• "SQL Everywhere" is a Sybase trademark
• Connection to database takes up alot of memory in application
• Making small database on iPaq
• SQL Server CE problem
• Will PPC 2003 DLL's for SQL CE work on WM5 PPC
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• SQL 2005 Mobile : The file is not a vali
• SQLMobile replication to SQL Server 05 6
• SQL Everywhere - Can't connect from VS.N
• rda.push error
• Windows Mobil ??SQL- Symbol MC70 Problem
• Has anyone noticed a size difference bet
• SQLMobile 2005 IIS 5.1 problems
• Can't find PInvoke sqlceme30.dll
• CREATE INDEX statement for SQL Mobile no
• Compact Database Error Code: 0
• @@ROWCOUNT Support???
• BLOB Merge Replication
• SQL Server Mobile Bug?
• Really need to use this query - but it h
• Error in Synchronizing Data

Hot Articles

• Query:how to transfer data from a .net a
• Is IIS always required for replication?
• Setting up Sql Mobile subscription
• DateTime.Min won't insert into SQL Serve
• An incorrect or unsupported HTTP functio
• Subscription Error 415
• SOS, please help
• Help SQL CE Query - LOW Performance
• SQL Mobile 2005 NVarChar Truncation Prob
• Parameterized Query Using Wildcards in V
• SQL Server CE 2.0 to SQL Server 2005 Exp
• SQL Server Mobile with Visual Studio 2003
• Copy SQL Server 2005 DB to SQL Server Mo
• Where is DataDirectory ?
• I am not sure whether I can use sql mobi

Recommend Articles

• Remote synchronise from PDA to SQL Serve
• String truncate error
• ssevaccesssync service does not start
• (SQL Mobile)Can SELECT, but cannot INSER
• Background replication
• Deploy Problem--failed with big files!
• ResultSet in Avalon (WinFX-WPF-.net3.0)
• Replication Error 28559
• Visual Studio Configure Sync Settings di
• How many Mobile DB's can sync with one s
• SqlCeResultSet - Problem After Deleting
• Smart Device CAB Project Detected Depend
• SQL Server 2005 Mobile: problem with con
• Synchronizing Data Within SQLCE and SQL
• Really need to use this query - but it h