안녕하세요, 저는 Windows Mobile 5.0 (.Net 2.0) 에서 일하고 있으며, 독자가 항상 null 인 작은 문제에 갇혀 있습니다. 내 연결은 괜찮아요. 그리고 다른 모든 것들이 괜찮다고 믿습니다. 유일한 문제는 독자입니다. 내 예외 캐치에서 그것은SqlCeDataReader는 항상 null입니다.
((System.Data.SqlServerCe.SqlCeException)(e)) : {"The operation completed successfully."}
InnerException: Could not evaluate expression
내 데이터베이스 파일 I 응용 프로그램 외부로 열 손상되지 모든 것이 잘 보이는 말한다. 내 코드는 다음과 같다 :
public static List<Image> GetAll(BOI caller)
{
List<Image> images = new List<Image>();
SqlCeConnection c = Connection.GetConnection(caller.ConnectionString);
if (c != null)
{
SqlCeCommand command = new SqlCeCommand("SELECT * FROM Images", c);
SqlCeDataReader reader = null;
try
{
reader = command.ExecuteReader(); <<<<< reader is null <<<<<<<
}
catch (Exception e)
{
while (reader != null && reader.Read())
{
Image temp = new Image((int)reader["imageKey"],
(String)reader["filename"],
(byte[])reader["image"],
(reader["labelKey"] == DBNull.Value ? null : (int?)reader["labelKey"]),
(int)reader["priority"]);
temp.SetDBName(caller.ConnectionString);
images.Add(temp);
}
}
}
return images;
}
편집 내가 Connection.GetConnection 내 연결 (..)를 엽니 다;
편집 : 2 e.StackTrace :
at System.Data.SqlServerCe.SqlCeDataReader.ProcessResults(Int32 hr)
at System.Data.SqlServerCe.SqlCeDataReader.FillMetaData(SqlCeCommand command)
at System.Data.SqlServerCe.SqlCeCommand.InitializeDataReader(SqlCeDataReader reader, Int32 resultType)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader()
at Oralys.BOI.DataAccess.ImageMapper.GetAll(BOI caller)
at Oralys.BOI.BOI.get_Images()
at Oralys.BOI.BOI_Controller.FetchAllImages()
at IdeoVoiceMobile.RunProfile.InitBOI()
at IdeoVoiceMobile.RunProfile..ctor()
at IdeoVoiceMobile.Program.startProfile()
at IdeoVoiceMobile.Program.Main()
얻기 연결 기능 :
public static SqlCeConnection GetConnection(string connectionString)
{
SqlCeConnection conn = null;
try
{
if (connections.Count == 0)
{
OpenConnection(connectionString);
}
conn = connections[connectionString];
}
catch (System.Exception)
{
}
return conn;
}
편집 : 3 예외 코드를 사용하여
cm.executereader 예외가 발생하지 않는 한SqlCeCommand command = new SqlCeCommand("SELECT * FROM Images Where imageKey=6", c);
ExceptionCode: 0xc0000005
ExceptionAddress: 0x0115438c
Reading: 0x00000000
Faulting module: sqlceqp35.dll
Offset: 0x0001438c
at NativeMethods.GetKeyInfo(IntPtr pIUnknown, IntPtr pTx, String pwszBaseTable, IntPtr prgDbKeyInfo, Int32 cDbKeyInfo, IntPtr pError)
at SqlCeDataReader.FillMetaData(SqlCeCommand command)
at SqlCeCommand.InitializeDataReader(SqlCeDataReader reader, Int32 resultType)
at SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at SqlCeCommand.ExecuteReader(CommandBehavior behavior)
at SqlCeCommand.ExecuteReader()
at ImageMapper.GetAll(BOI caller)
at BOI.get_Images()
at BOI_Controller.FetchAllImages()
at RunProfile.InitBOI()
at RunProfile..ctor()
at Program.startProfile()
at Program.Main()
다음 몇 줄의 코드를 표시하면 도움이 될 것입니다. –
명시 적으로 연결을 볼 수 없습니까? GetConnection에 있나요? – rrrr
그래, 내 질문을 편집하려고 했어. – raym0nd