La consulta LIKE en una base de datos de Access a través de C # siempre devuelve COUNT (*) de 0
Por favor mira en el siguiente código:
using (OleDbConnection openCon = new OleDbConnection(ConfigurationManager.AppSettings["AccessConnectioString"]))
{
openCon.Open();
string tc = string.Empty;
string ttc = string.Empty;
if (!string.IsNullOrEmpty(QSetId))
{
tc = "select count(*) as [Count] from ABC where QSetId = @qSetId and TText like 'RT*'";
}
else
{
tc = "select count(*) as [Count] from PQR where TText like 'RT*'";
}
using (OleDbCommand qtc= new OleDbCommand(tc))
{
qtc.Connection = openCon;
if (!string.IsNullOrEmpty(QSetId))
qtc.Parameters.Add("@qSetId", OleDbType.VarChar).Value = QSetId;
OleDbDataReader dr1 = qtc.ExecuteReader();
while (dr1.Read())
{
ttCnt = (int)dr1["Count"];
}
}
openCon.Close();
}
Siempre obtengo recuento como 0 en lugar de algún valor entero. Durante la depuración tomo la consulta y la ejecuto en MS ACCESS 2013, me da un resultado correcto. No entiendo cuál es el problema.