0
C#에서는 행이 있음을 반환하는 ODBCDataReader가 있지만 데이터에 액세스하려고하면 개체 오류 참조로 설정되지 않은 개체가 반환됩니다. db 직접 SQL을 테스트하고 null이없는 행을 반환합니다.ODBCDataReader에는 행이 있지만 데이터에 액세스 할 수 없습니다.
OdbcDataReader results;
try
{
// Initialize & open odbc connection
using (OdbcConnection conn = new OdbcConnection(connectionString.ToString()))
{
conn.Open();
// Initialiaze odbc command object
using (OdbcCommand comm = new OdbcCommand(query.ToString(), conn))
{
results = comm.ExecuteReader();
}
}
}
catch
{
//detailed error messaging here (which does not get hit)
}
temp = results;
if (temp.HasRows == false)
{
//error messaging here does not get hit.
}
while (temp.Read())
{
try
{
//I attempted to access the data by creating an object array:
object [] objarray = new object[temp.FieldCount)
temp.GetValues(objarray); //this causes error
}
catch{ // error is caught here "object not set to a reference of an object" }
for (i = 0; i < temp.FieldCount; i++)
{
try
{
//I also attempted other ways to access the data including:
temp[i].ToString(); // this causes error
temp.GetInt32(i).ToString(); // this causes error
temp.GetName(i); //this causes error
}
catch
{
// error is caught here "object not set to a reference of an object"
}
}
}
답변을 게시하려고했지만 표시되지 않아서 여기에서 시도해 보겠습니다. 문제는 코드와 관련이 없으며 (올바르게 작동 함) 데이터베이스 동기화 문제였습니다. – user2904607