المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ODBC Data Error



C# Programming
09-23-2009, 08:41 PM
Hi, I am trying to connect to Sybase SQLAnyWhere DB from C# using ODBC Data Connection.
I am getting the below error.

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

Can anyone tell me the reason for that ?

Error Report :
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Data.Common.UnsafeNativeMethods.SQLExecDirectW(OdbcStatementHandle StatementHandle, String StatementText, Int32 TextLength)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Odbc.OdbcCommand.ExecuteReader()


I have a list of command strings.
I am exceuting the following commands in for loop.
foreach (string str in stringlist)
{
OdbcCommand defineTankCMD = Conn.CreateCommand();
defineTankCMD.CommandText = str;
OdbcDataReader defineTankReader = defineTankCMD.ExecuteReader();
defineTankReader.Close();
}

Is it OK. some times it is working fine and some times it was giving error.