ExceptionCode:带有sqlcereader的0xc0000005

时间:2012-12-20 09:40:45

标签: .net-3.5 sql-server-ce windows-ce smart-device smart-device-framework

我有一个Windows CE设备。我正在尝试运行使用SqlServerCe的应用程序。当我尝试运行ExecuteReader.Read()方法时,它会抛出如下所示的异常:

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()

Sql的其他方法不会导致问题(如ExecuteNonQuery)。

我在该设备上安装了Microsoft SQL Server Compact Edition \ v3.5和.NET Framework 3.5。

我正在使用VS 2008智能设备应用程序进行开发。

 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());
            }
        }

这就是预期发生的功能。

0 个答案:

没有答案