digitalmars.D.learn - ODBC Library?
- Charles (7/7) Nov 10 2014 Hi guys,
- Adam D. Ruppe (6/6) Nov 10 2014 I kinda slapped one together but idk if it actually works.
- Charles (5/18) Nov 10 2014 It didn't compile, says, "mssql.d(12): Error: module sql is in
- Adam D. Ruppe (7/9) Nov 10 2014 Oh, I forgot I used those. You can download the win32 folder from
- Sean Kelly (8/13) Nov 10 2014 Assuming you're using ODBC on Windows, here's an old port of an
- Sean Kelly (38/38) Nov 10 2014 Oh, here's a sample, since it doesn't look like that zip includes
Hi guys, I've been looking and haven't found any libraries for ODBC or MSSQL. I saw some for D v1, but nothing for v2. Anyone know of any, or anyone know of a tutorial that I could use to create this myself? Thanks, Charles
Nov 10 2014
I kinda slapped one together but idk if it actually works. https://github.com/adamdruppe/arsd database.d and mssql.d from that repo. I haven't even tried to compile it for a while though, so it might not work at all. The way I made it was to write the extern(C) function declarations and then call it like in C.
Nov 10 2014
I kinda slapped one together but idk if it actually works. https://github.com/adamdruppe/arsd database.d and mssql.d from that repo. I haven't even tried to compile it for a while though, so it might not work at all. The way I made it was to write the extern(C) function declarations and then call it like in C.It didn't compile, says, "mssql.d(12): Error: module sql is in file 'win32\sql.d' which cannot be read" and then lists the import paths, of which none of them have the win32 directory. Database.d was able to compile though.Assuming you're using ODBC on Windows, here's an old port of an even older C++ wrapper I used to use for ODBC work. It includes an ODBC header and library, so should serve as a good basis for whatever you're trying to do. If you're on Unix, you may have to update the ODBC header a bit. I got partway through that project back in the day but never finished: http://invisibleduck.org/sean/tmp/sql.zipI'll look into this, thanks for the example.
Nov 10 2014
On Monday, 10 November 2014 at 17:57:21 UTC, Charles wrote:It didn't compile, says, "mssql.d(12): Error: module sql is in file 'win32\sql.d' which cannot be read"Oh, I forgot I used those. You can download the win32 folder from here https://github.com/AndrejMitrovic/DWinProgramming/tree/master/WindowsAPI The Windows bindings that come with phobos are pathetically incomplete so a separate download or a bunch of copy/pasted declarations is needed for any serious windows api work.
Nov 10 2014
On Monday, 10 November 2014 at 18:13:58 UTC, Adam D. Ruppe wrote:On Monday, 10 November 2014 at 17:57:21 UTC, Charles wrote:Thanks for that. For anyone in the future: I needed odbc32.lib, so I created the following odbc32.def and used implib. LIBRARY odbc32 EXETYPE NT SUBSYSTEM WINDOWS EXPORTS _SQLAllocEnv 4 = SQLAllocEnv _SQLAllocConnect 8 = SQLAllocConnect _SQLAllocHandle 12 = SQLAllocHandle _SQLColAttribute 28 = SQLColAttribute _SQLConnect 28 = SQLConnect _SQLDisconnect 4 = SQLDisconnect _SQLDescribeCol 36 = SQLDescribeCol _SQLDriverConnect 32 = SQLDriverConnect _SQLDrivers 32 = SQLDrivers _SQLDataSources 32 = SQLDataSources _SQLExecDirect 12 = SQLExecDirect _SQLFetch 4 = SQLFetch _SQLFreeConnect 4 = SQLFreeConnect _SQLFreeHandle 8 = SQLFreeHandle _SQLFreeEnv 4 = SQLFreeEnv _SQLEndTran 12 = SQLEndTran _SQLFreeStmt 8 = SQLFreeStmt _SQLGetData 24 = SQLGetData _SQLGetDiagField 28 = SQLGetDiagField _SQLGetDiagRec 32 = SQLGetDiagRec _SQLGetInfo 20 = SQLGetInfo _SQLNumResultCols 8 = SQLNumResultCols _SQLSetConnectOption 12 = SQLSetConnectOption _SQLSetEnvAttr 16 = SQLSetEnvAttr _SQLSetStmtOption 12 = SQLSetStmtOption I've only tested it on a couple select statements and the fieldNames, but so far its working.It didn't compile, says, "mssql.d(12): Error: module sql is in file 'win32\sql.d' which cannot be read"Oh, I forgot I used those. You can download the win32 folder from here https://github.com/AndrejMitrovic/DWinProgramming/tree/master/WindowsAPI The Windows bindings that come with phobos are pathetically incomplete so a separate download or a bunch of copy/pasted declarations is needed for any serious windows api work.
Nov 10 2014
On Monday, 10 November 2014 at 20:37:51 UTC, Charles wrote:For anyone in the future: I needed odbc32.lib, so I created the following odbc32.def and used implib.Thanks me. My computer I was using recently died, and ran into this problem again when getting everything set up. Is there any way to just fix this issue altogether?
Oct 31 2015
On Monday, 10 November 2014 at 16:01:21 UTC, Charles wrote:Hi guys, I've been looking and haven't found any libraries for ODBC or MSSQL. I saw some for D v1, but nothing for v2. Anyone know of any, or anyone know of a tutorial that I could use to create this myself?Assuming you're using ODBC on Windows, here's an old port of an even older C++ wrapper I used to use for ODBC work. It includes an ODBC header and library, so should serve as a good basis for whatever you're trying to do. If you're on Unix, you may have to update the ODBC header a bit. I got partway through that project back in the day but never finished: http://invisibleduck.org/sean/tmp/sql.zip
Nov 10 2014
Oh, here's a sample, since it doesn't look like that zip includes one: import sql.Connection; import sql.Exception; import sql.ResultSet; import sql.Statement; import core.stdc.stdio; pragma( lib, "odbc32.lib" ); pragma( lib, "sql.lib" ); void main() { try { auto conn = new Connection( "driver={SQL Server};" "server=(local);" "trusted_connection=no;" "database=test;" "uid=sa;" "pwd=hello;" ); //"network=dbmssocn;" ); auto stmt = conn.prepare( "SELECT Name FROM Person WHERE PersonID = ?" ); stmt[0] = 1; //auto stmt = conn.prepare( "SELECT Name FROM Person" ); auto rs = stmt.open(); printf( "%.*s\n----\n", rs[0].name ); while( rs.next() ) printf( "%.*s\n", rs[0].asUtf8 ); } catch( SQLException e ) { foreach( rec; e ) { printf( "%.*s - %d: %.*s\n", rec.state, rec.code, rec.msg ); } } }
Nov 10 2014