My code is the following:
void countVR(int kk){
string selectString = "SELECT COUNT(*) FROM cllohn" + (Jahr % 100).ToString("00") + " WHERE lzVSTR="+kk;
if(filtsel == selstr){
using (IDbConnection con = DatabaseFactory.Connect("CL" + (Jahr % 100).ToString("00"), true)) {
//con.Open();
using (IDbCommand cmd = con.CreateCommand()) {
cmd.CommandText = selectString;
using (IDataReader reader = cmd.ExecuteReader()) {
while(reader.Read()){
zeilenCount = reader.GetAsInteger(0);
//System.Diagnostics.Debug.WriteLine("Zeilen in " + kk + ": " +zeilenCount);
}
}
}
}
}
This is the Error i get:
System.Transactions Critical: 0 : http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledUnbehandelte AusnahmeCONTELDA2.exeSystem.Data.Odbc.OdbcException, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089ERROR [22018] [Microsoft][ODBC SQL Server Driver][SQL Server]Fehler beim Konvertieren des varchar-Werts '..' in den int-Datentyp.
if i add " AND lzBEST='VR'" to the SELECT Statement, it works again, but i want to count all entries for lzVSTR=kk (whatever the number may be) not only the ones with lzBEST='VR'