T
tiger79
Hi,
I've implemented the following code :
public int Count()
{
int count=0;
SqlCeConnection con = new SqlCeConnection(@"Data Source=\My
Documents\DICT.sdf");
con.Open();
string tSQL = "SELECT COUNT(*) FROM Entity";
SqlCeCommand cmdSelect = new SqlCeCommand(tSQL, con);
cmdSelect.CommandType = CommandType.Text;
SqlCeDataReader dtr = cmdSelect.ExecuteReader(CommandBehavior.Default);
count = dtr.GetInt32(0);
con.Close();
return count;
}
Ok, the code seems quite straight-forward to me. I got a Table (Entity) in a
database (DICT.sdf). Now I'd like to know how many rows are in this table.
So I use the COUNT aggregate function of SQL. The returned value I want to
place in the int variable count. I do so by making a datareader and reading
the value from there....
But i get the following error :
No data exist for the Row/Column
I dont really understand what's meant with that and how to get it to work...
Any ideas ???
I've implemented the following code :
public int Count()
{
int count=0;
SqlCeConnection con = new SqlCeConnection(@"Data Source=\My
Documents\DICT.sdf");
con.Open();
string tSQL = "SELECT COUNT(*) FROM Entity";
SqlCeCommand cmdSelect = new SqlCeCommand(tSQL, con);
cmdSelect.CommandType = CommandType.Text;
SqlCeDataReader dtr = cmdSelect.ExecuteReader(CommandBehavior.Default);
count = dtr.GetInt32(0);
con.Close();
return count;
}
Ok, the code seems quite straight-forward to me. I got a Table (Entity) in a
database (DICT.sdf). Now I'd like to know how many rows are in this table.
So I use the COUNT aggregate function of SQL. The returned value I want to
place in the int variable count. I do so by making a datareader and reading
the value from there....
But i get the following error :
No data exist for the Row/Column
I dont really understand what's meant with that and how to get it to work...
Any ideas ???