Once in a while I see in the logs, this exception:
12:27:38,504 [8] DEBUG - Inside GetRoles USER1
12:27:38,537 [8] ERROR - Error in method, "GetRoles" . User account that invoked error- USER1
System.Data.OleDb.OleDbException (0x80004005): SQL0401: Comparison operator = operands not compatible.
Cause . . . . . : The operands of comparison operator = are not compatible. -- Numeric operands are compatible with any other numeric operands and with character and graphic operands. -- Character operands are compatible with operands that are character, graphic, date, time, timestamp, or numeric. -- Date, time, and timestamp operands are compatible with character and graphic operands or with another operand of the same type. -- Graphic operands are compatible with graphic, character, date, time, timestamp, or numeric operands. -- Binary operands are compatible only with binary operands. -- Operands that are user-defined types can only be compared to operands that are the same exact type. -- DataLink and XML operands cannot be compared. Recovery . . . : Check the data types of all operands to see if the data types are compatible. If all the operands of the SQL statement are correct and a view is being accessed, then check the data types of all the operands in the view definition. Correct the errors. Try the request again.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at Dashboard.DataAccessLayer.DAL.GetRoles() in DAL.cs:line 98
And here is my code:
public List<string> GetRoles()
{
List<string> tempList = new List<string>();
OleDbConnection connection;
OleDbCommand command;
string sql = null;
sql = "SELECT ROLE FROM " + LibraryList.PROJ + ".ROLE where UPPER(USERID) = UPPER(?)";
using (connection = new OleDbConnection(_connectionString))
{
using (command = new OleDbCommand())
{
try
{
connection.Open();
command.Connection = connection;
command.Parameters.Add("@userID", OleDbType.Char, 10).Value = CurrentUser.getUserID();
log.Debug("Inside GetRoles " + CurrentUser.getUserID());
command.CommandText = sql;
using (OleDbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
tempList.Add(reader.GetString(0));
}
}
}
catch (Exception ex)
{
log.Error("Error in method, \"GetRoles\" . User account that invoked error- " + CurrentUser.getCurrentUserDisplayInfoForLogging(), ex);
}
}
}
return tempList;
}
I print out the value and it is a string, so it's not null or empty or anything. This happens very infrequently so it's hard to pin point what is happening when it seems the value is the same as any other time but sometimes it doesn't like it.
What issue could be causing this?