Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

  • Thread starter Thread starter Jeff0803
  • Start date Start date
J

Jeff0803

Guest
Following error occur on and off.

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

Here is the code snipet that error occur.

public void GetMessageCreateTimeInRemindHistory(List<DateTime> messagecreatetimelist)
{
string sret = "";
string SelectSQL = "SELECT patient_id, message_datetime, " +
"direction, message_body FROM reminder_history " +
"WHERE direction = 2 " +
"AND (message_body = '1' OR UCase(message_body) = 'NO')";

using (OleDbConnection conn_CDMR = new OleDbConnection(ConnectionString_CDMR))
{
messagecreatetimelist.Clear();
try
{
using (OleDbCommand command = new OleDbCommand(SelectSQL, conn_CDMR))
{
conn_CDMR.Open();
OleDbDataReader reader = command.ExecuteReader(); <===== Error here!
if (reader.HasRows)
{
while (reader.Read())
{
if (DBNull.Value.Equals(reader.GetDateTime(1)) == false)
{
DateTime dt = new DateTime();
dt = Convert.ToDateTime(reader.GetDateTime(1));
messagecreatetimelist.Add(dt);
}
}
}
reader.Close();
conn_CDMR.Close();
sret = SelectSQL;
}
}
catch (Exception e)
{
WriteLog("GetMessageCreateTimeInRemindHistory() failed.");
}
}
return;
}

Error occur at OleDbDataReader reader = command.ExecuteReader();

Can anybody give me some advise?

Continue reading...
 
Back
Top