[Mono-list] ExecuteReader problem

russell.kay at realtimeworlds.com russell.kay at realtimeworlds.com
Wed Oct 11 13:05:13 EDT 2006


All,

I'm trying out ODBC on MAC OSX and I'm getting an exception every time I
try to do an ExecuteReader call

The exception output is....

Unhandled Exception: System.ArgumentOutOfRangeException: ArgRange_Array
Parameter name: count
  at System.Text.ASCIIEncoding.GetString (System.Byte[] bytes, Int32
index, Int32 count) [0x00000] 
  at System.Data.Odbc.OdbcDataReader.GetColumnAttributeStr (Int32
column, FieldIdentifier fieldId) [0x00000] 
  at System.Data.Odbc.OdbcDataReader.GetSchemaTable () [0x00000] 
  at System.Data.Odbc.OdbcDataReader..ctor (System.Data.Odbc.OdbcCommand
command, CommandBehavior behavior) [0x00000] 
  at System.Data.Odbc.OdbcDataReader..ctor (System.Data.Odbc.OdbcCommand
command, CommandBehavior behavior, Int32 recordAffected) [0x00000] 
  at (wrapper remoting-invoke-with-check)
System.Data.Odbc.OdbcDataReader:.ctor
(System.Data.Odbc.OdbcCommand,System.Data.CommandBehavior,int)
  at System.Data.Odbc.OdbcCommand.ExecuteReader (CommandBehavior
behavior) [0x00000] 
  at System.Data.Odbc.OdbcCommand.ExecuteDbDataReader (CommandBehavior
behavior) [0x00000] 
  at System.Data.Common.DbCommand.ExecuteReader () [0x00000] 
  at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader
() [0x00000] 
  at DatabaseTest.Program.Main (System.String[] args) [0x00000]

The code I am executing is

    class Program
    {
        static void Main(string[] args)
        {
            //connect to the database at
            //IDbConnection conn = new OdbcConnection(
"DSN=RealTrading;USER=root;PASSWORD=root;" );
            IDbConnection conn = new OdbcConnection("DRIVER={MySQL ODBC
3.51
Driver};SERVER=<ServerName>;DATABASE=<databasename>;USER=<user>;PASSWORD
=<password>;OPTION=3;");
            Console.WriteLine("Connecting to database....");
            conn.Open();


			Stopwatch sw = new Stopwatch();
            IDbCommand dbcmd = conn.CreateCommand();
            dbcmd.CommandText = "SELECT * FROM table WHERE NumLines>10";
            Console.WriteLine( "Executing SQL" );
            sw.Start();
            IDataReader reader = dbcmd.ExecuteReader();
            sw.Stop();
            Console.WriteLine("Elapsed Time = {0}", sw.Elapsed);
            int n = 0;
            while( reader.Read() && (n<20) ) {
                Console.WriteLine( "Sector {0} TOID {1} NumLines {2}
Date {3}", reader["Sector"], reader["TOID"], reader["NumLines"],
reader["Date"] );
                ++n;
            } // end while
            reader.Close();
            reader = null;
            dbcmd.Dispose();
            dbcmd = null;
            conn.Close();
            conn = null;
        }
    }

Any Ideas????

Russell


More information about the Mono-list mailing list