[Mono-list] OdbcParameters seem not to work in Mono 1.1.7

lunkwill@gmx.net lunkwill@gmx.net
Wed, 11 May 2005 13:43:25 +0200 (MEST)

Hey all!

Once again a problem with ODBC. I want to build queries using OdbcParameter.
This seems not to work with Mono 1.1.7 on Linux (SLES9) and WinXP (testet it
with Pacos 1.1.7 Installer). 
I can reproduce the problem with Firebird and Informix. So it seems not to
be an ODBC issue.
My test program only fails with Mono. I get the expected results when using
MS .Net

My example looks like this:

OdbcCommand cmdFail = conn.CreateCommand();
cmdFail.CommandText = "SELECT * FROM t_odbc_test WHERE last_name = ?";
cmdFail.Parameters.Add("P1", OdbcType.VarChar);
cmdFail.Parameters["P1"].Value = "Dent";
OdbcDataReader readerFail = cmdFail.ExecuteReader();
while (readerFail.Read())
   Console.WriteLine("--> " + readerFail["LAST_NAME"]);

With MS.NET I get the expected result. On Mono I get:

Object reference not set to an instance of an object
in <0x00000> <unknown method>
in (wrapper managed-to-native) System.Data.Odbc.libodbc:SQLExecute (intptr)
in <0x00052> System.Data.Odbc.OdbcCommand:ExecSQL (System.String sql)
in (wrapper remoting-invoke-with-check) System.Data.Odbc.OdbcCommand:ExecSQL
in <0x00076> System.Data.Odbc.OdbcCommand:ExecuteNonQuery (Boolean
in (wrapper remoting-invoke-with-check)
System.Data.Odbc.OdbcCommand:ExecuteNonQuery (bool)
in <0x00015> System.Data.Odbc.OdbcCommand:ExecuteReader (CommandBehavior
in (wrapper remoting-invoke-with-check)
System.Data.Odbc.OdbcCommand:ExecuteReader (System.Data.CommandBehavior)
in <0x0000f> System.Data.Odbc.OdbcCommand:ExecuteReader ()
in (wrapper remoting-invoke-with-check)
System.Data.Odbc.OdbcCommand:ExecuteReader ()
in <0x001b5> MainClass:Main (System.String[] args)

I suspect that the parameters value is not set correctly...

Any help would be really appreciated. Let me know if someone wants a
complete test case.


+++ Neu: Echte DSL-Flatrates von GMX - Surfen ohne Limits +++
Always online ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl