[Mono-list] Problem with ODBC Driver
Alan Tam
Tam@SiuLung.com
Wed, 21 May 2003 04:12:25 +0800
It is because the ODBC data provider currently only implemented String, Int32
and no more other datatypes.
Regards,
Alan
----- Original Message -----
From: "Olivier Gaumond" <ogaumond@yahoo.com>
To: <mono-list@lists.ximian.com>
Sent: 2003-05-21 03:37
Subject: [Mono-list] Problem with ODBC Driver
> I created the following table in MySQL test database
> create table employee (firstname varchar(32), lastname varchar(32));
>
> I can retrieve data from the database with the Mono.Data.MySql provider but
not
> with the ODBC provider.
>
> I have unixODBC and MyODBC installed and working and I added a DSN to connect
> to the database. I can succesfully test the DSN and connection with unixODBC
> DataManager.
>
> To avoid errors when testing with Mono I had to symlink
/usr/local/libodbc32.so
> to /usr/local/libodbc.so and export LD_LIBRARY_PATH=/usr/local/lib
>
> Here are the tests I made in sqlsharp to demonstrate the errors.
>
> With the Mono.Data.MySql provider
>
> SQL# \Provider MySql
> The default Provider is LOADEXTPROVIDER
> Assembly: Mono.Data.MySql
> Connection Class: Mono.Data.MySql.MySqlConnection
>
> SQL# \ConnectionString SERVER=localhost;DATABASE=test;UID=test;PASSWORD=test;
>
> SQL# \Open
> Attempt to open connection...
> Loading external provider...
>
> ** (sqlsharp.exe:7934): WARNING **: Failed to load function my_thread_end
from
> libmySQL
>
> ** (sqlsharp.exe:7934): WARNING **: Failed to load function my_thread_end
from
> libmySQL
>
> ** (sqlsharp.exe:7934): WARNING **: Failed to load function my_thread_init
from
> libmySQL
>
> ** (sqlsharp.exe:7934): WARNING **: Failed to load function my_thread_init
from
> libmySQL
> External provider loaded.
> Open was successfull.
>
> SQL# SELECT * FROM employee;
> Execute SQL: SELECT * FROM employee;
> Display any result sets...
> Display the result set 1
> Fields in Query Result: 2
>
> firstname lastname
> ========= ========
>
> Joe Bloe
> John Smith
> Scott Tiger
>
> Rows retrieved: 3
>
> ----
>
> With the ODBC Driver
>
> SQL# \Provider odbc
> The default Provider is ODBC
>
> SQL# \ConnectionString DSN=test;UID=test;PWD=test;
>
> SQL# \Open
> Attempt to open connection...
>
> ** (sqlsharp.exe:7934): WARNING **: byref boolean marshalling not inplemented
> Open was successfull.
>
> SQL# SELECT * FROM employee;
> Execute SQL: SELECT * FROM employee;
> Display any result sets...
> Display the result set 1
> Fields in Query Result: 2
>
> firstname lastname
> =================== ===================
>
> Error: System.InvalidCastException: Cannot cast from source type to
destination
> type
> in <0x0002f> 00 System.Data.Odbc.OdbcDataReader:GetDateTime (int)
> in <0x0083e> 00 Mono.Data.SqlSharp.SqlSharpCli:DisplayResult
> (System.Data.IDataReader,System.Data.DataTable)
> in <0x00028> 00 Mono.Data.SqlSharp.SqlSharpCli:OutputQueryResult
> (System.Data.IDataReader,System.Data.DataTable)
> in <0x000d7> 00 Mono.Data.SqlSharp.SqlSharpCli:DisplayData
> (System.Data.IDataReader)
> in <0x00106> 00 Mono.Data.SqlSharp.SqlSharpCli:ExecuteSql (string)
>
>
> The driver seems to always return DateTime from GetFieldType().
>
> To run the sample from http://www.go-mono.com/odbc.html I had to change two
> lines
> string FirstName = reader["firstname"];
> string LastName = reader["lastname"];
> to
> string FirstName = reader.GetString(0);
> string LastName = reader.GetString(1);
>
>
> Should I fill a bug report about that?
>
> Olivier
>
> __________________________________________________________
> Lèche-vitrine ou lèche-écran ?
> magasinage.yahoo.ca
> _______________________________________________
> Mono-list maillist - Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>