[Haskell-cafe] HDBC with SQL Server / OBDC

Andrew Appleyard andrew.appleyard at gmail.com
Sun May 25 20:04:42 EDT 2008


Hi Morten,

On 26/05/2008 2:24 AM, you wrote:
> am trying to do a simple DB connection from Haskell to a SQL Server 2005 
> (on Windows obviously). The DSN name ("Nylon") works from C++ but when 
> running the below example (or any other I can think of) ghci crashes.
> Does anyone know a resolution for this or where the problem can possible 
> be ?

I had the same problem last week.  I found that GHCi would silently 
crash, but GHC would give link errors on the foreign imported functions 
from the odbc32 library.  Changing the calling convention from 'ccall' 
to 'stdcall' for the 16 'sql.h' imports fixed the problem for me, but 
I'm not convinced that's the 'right way' to fix it (ccall is surely the 
appropriate calling convention for using ODBC on Unix, for example).

> GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
> Loading package base ... linking ... done.
> Prelude> :m Database.HDBC
> Prelude Database.HDBC> :m + Database.HDBC.ODBC
> Prelude Database.HDBC Database.HDBC.ODBC>  do { conn <- connectODBC 
> "DSN=Nylon"; xs <- getTables conn; putStr $ head xs; }
> Loading package array-0.1.0.0 ... linking ... done.
> Loading package containers-0.1.0.1 ... linking ... done.
> Loading package bytestring-0.9.0.1 ... linking ... done.
> Loading package old-locale-1.0.0.0 ... linking ... done.
> Loading package old-time-1.0.0.0 ... linking ... done.
> Loading package mtl-1.1.0.0 ... linking ... done.
> Loading package HDBC-1.1.4 ... linking ... done.
> Loading package HDBC-odbc-1.1.4.3 ... linking ... done.
> CRASH !!!

Regards,
Andrew


More information about the Haskell-Cafe mailing list