I'm a total newby (except for Borland Delphi database handling). This
function is being run on compact framework. MS visual studio 2003 c# .net
for pocketpc.
When stepping through in debug mode, the program is failing on the
"rs.Open(QueryString[nCount],cn" line.
The exception.message I'm getting is "InvalidConnection"
I'm using the same code elsewhere in the program to open the AdoceConnection
object. There I fill a dataset which I bind to a data grid. That works fine
so I believe my cn object is fine.
(My localdatabase has spaces in the path, does that matter?)
public static string LocalDatabase = "\\My Documents\\PocketVibrAPro.cdb";
public static string LocalConnection = "Data Source=" + LocalDatabase;
public static int CountReadings(ref int TotalReadings)
{
int[] result = new int[2];
string[] QueryString = new string[2];
QueryString[0] = "SELECT * FROM tblDataFiles";
QueryString[1] = "SELECT * FROM tblAssets";
if (DatabaseExists)
{
try
{
for (int nCount = 0; nCount < 2; nCount++)
{
AdoceConnection cn = new AdoceConnection(LocalConnection);
try
{
InTheHand.Data.Adoce.Recordset rs = new InTheHand.Data.Adoce.Recordset();
try
{
rs.Open(QueryString[nCount], cn);// << InvalidConnection error here
try
{
result[nCount] = rs.Count;
}
finally
{
rs.Close();
}
}
finally
{
rs.Dispose();
}
}
finally
{
cn.Close();
cn.Dispose();
}
}
}
catch(Exception e)
{
SystemHelper.ShowException("Error counting records", e);
return 0;
}
}
TotalReadings = result[1];
return result[0];
}//public static int CompletedReadings(ref int TotalReadings)