Newby. Retrieving values from a sql query

  • Thread starter Thread starter Claire
  • Start date Start date
C

Claire

Sorry, Im very new to this.
Visual studio .net compact framework. Working on an Access database on a
pocket PC

What I want to know is how to retrieve values (not records) from an SQL
query. In this case it's to retrieve the total number of records in my
table.
My code is as follows, now I'm stuck.

string LocalConnection = "Data Source="\My Documents\PocketVibrAPro.cdb";

string QueryString = "SELECT COUNT(*) FROM TBLDATAFILES";

AdoceConnection cn = new AdoceConnection(LocalConnection);

AdoceDataAdapter DataAdapter = new AdoceDataAdapter(QueryString, cn);
 
ADOCE doesn't support the COUNT(*) operator in SQL it has only a limited
subset of SQL there is a reference here:-
http://www.inthehand.com/documentation/adoce/sql/

What you can do to workaround this is create a Recordset and query it's
Count property e.g.

string LocalConnection = "Data Source="\My Documents\PocketVibrAPro.cdb";
string QueryString = "SELECT * FROM TBLDATAFILES";
AdoceConnection cn = new AdoceConnection(LocalConnection);
Recordset rs = new Recordset();
rs.Open(QueryString, cn);
int count = rs.Count;

rs.Close();
rs.Dispose();

cn.Close()
cn.Dispose();


Peter
 
Back
Top