Reputation: 33
I have a Windows CE Device. I am trying to run an application which is using SqlServerCe. When I try to run ExecuteReader.Read()
method it is throwing an exception like below:
Error
ExceptionCode: 0xc0000005
Exception Adress : 0x4d776569
Reading: 0x4d776568
at
NativeMethods.GetKeyInfo(IntPtrpTx,String pwszBase Table, IntPtrprgDbKeyInfo, Int 32 cDKeyInfo, IntPtr pError)
at
SqlCeDataReader.FillMetaData(SqlCeCommand command)
at
SqlCeCommand.InitializeDataReader(SqlCeDataReader reader, Int32 resultType)
at
SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResulSetOptions options)
at
SqlCeCommand.ExecuteReader(CommandBehavior behavior)
at
Prothocol.checkReadACK(SerialPort serialport,SqlCeCommand sql_cmd)
at
Message.communicationThread()
The other methods of Sql doesn't cause a problem (Like ExecuteNonQuery).
I have Microsoft SQL Server Compact Edition\v3.5 and .NET Framework 3.5 on that device.
And I am using VS 2008 Smart Device Application for developing.
public static void checkReadACK(SerialPort serialport, SqlCeCommand sql_cmd)
{
String s;
long selectedID;
s = "SELECT receivedNum,id from MESSAGE_INBOX where (status = 2)"; //Status: 0 read and replied. 1 unread. 2 read and notreplied.
try
{
sql_cmd.CommandText = s;
sql_cmd.ExecuteNonQuery();
SqlCeDataReader reader = sql_cmd.ExecuteReader();
while (reader.Read())
{
sendReadACK(reader.GetString(0),serialport);
selectedID = reader.GetInt64(1);
s = "UPDATE MESSAGE_INBOX SET status = 0 WHERE (id = " + selectedID + ")";
sql_cmd.CommandText = s;
sql_cmd.ExecuteNonQuery();
}
}
catch //(Exception err)
{
// MessageBox.Show(err.Message.ToString());
}
}
And this is the function where expection occurs.
Upvotes: 1
Views: 1572