www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Database connection...

reply Nahon <lburger hu.tesco-europe.com> writes:
Hi.

(Sadly) I have to connect to a *MSSQL* database in my program. I browsed the
net quite a lot to find a D library (or sg.) that could do it. (I've found a
connector form MySQL and a few others but not MSSQL.)
Could someone help me about sending an URL for one or a module of own?

Thank you.
Oct 30 2006
next sibling parent Kyle Furlong <kylefurlong gmail.com> writes:
Nahon wrote:
 Hi.
 
 (Sadly) I have to connect to a *MSSQL* database in my program. I browsed the
 net quite a lot to find a D library (or sg.) that could do it. (I've found a
 connector form MySQL and a few others but not MSSQL.)
 Could someone help me about sending an URL for one or a module of own?
 
 Thank you.
Assuming you are comfortable with the windows api for odbc, the api headers are here: http://www.prowiki.org/wiki4d/wiki.cgi?WindowsAPI. Which will link you to the dsource repository.
Oct 30 2006
prev sibling next sibling parent reply Nahon <lburger hu.tesco-europe.com> writes:
Nahon wrote:
 Hi.

 (Sadly) I have to connect to a *MSSQL* database in my program. I browsed the
 net quite a lot to find a D library (or sg.) that could do it. (I've found a
 connector form MySQL and a few others but not MSSQL.)
 Could someone help me about sending an URL for one or a module of own?

 Thank you.
Assuming you are comfortable with the windows api for odbc, the api headers are here: http://www.prowiki.org/wiki4d/wiki.cgi?WindowsAPI. Which will link you to the dsource repository.
The dbi module collection would be great (although I wanted to avoid ODBC), but I've downloaded it and unpacked to dmd/src/phobos/dbi. Then in my program I added the line import dbi.odbc.odbcdatabase; //and tried dbi.odbc.all as well then wanted to create a new database object: OdbcDatabase x = new OdbcDatabase(); When linking I get these error messages: #myprg.obj(myprg) #myprg.obj(myprg) _D3dbi4odbc12OdbcDatabase12OdbcDatabase5_ctorFZC3dbi If I don't want to create a new instance (OdbcDatabase x;) it's fine but cannot be used. What have I done wrong?
Oct 30 2006
parent "JC" <johnch_atms hotmail.com> writes:
"Nahon" <lburger hu.tesco-europe.com> wrote in message 
news:ei4giu$i7c$1 digitaldaemon.com...
 The dbi module collection would be great (although I wanted to avoid 
 ODBC),
 but I've downloaded it and unpacked to dmd/src/phobos/dbi. Then in my 
 program
 I added the line
 import dbi.odbc.odbcdatabase; //and tried dbi.odbc.all as well
 then wanted to create a new database object:
 OdbcDatabase x = new OdbcDatabase();
 When linking I get these error messages:
 #myprg.obj(myprg)

 #myprg.obj(myprg)

 _D3dbi4odbc12OdbcDatabase12OdbcDatabase5_ctorFZC3dbi


 If I don't want to create a new instance (OdbcDatabase x;) it's fine but
 cannot be used.

 What have I done wrong?
This usually happend when you've not added the source files to the command line.
Oct 30 2006
prev sibling next sibling parent reply Nahon <lburger hu.tesco-europe.com> writes:
 When linking I get these error messages:
 #myprg.obj(myprg)

 #myprg.obj(myprg)

 _D3dbi4odbc12OdbcDatabase12OdbcDatabase5_ctorFZC3dbi


 If I don't want to create a new instance (OdbcDatabase x;) it's fine but
 cannot be used.

 What have I done wrong?
This usually happend when you've not added the source files to the command line.
Ok, I've ran into this problem before. But there's a *lot* of modules for this single one. How can I avoid the command line thing?
Oct 30 2006
parent "JC" <johnch_atms hotmail.com> writes:
"Nahon" <lburger hu.tesco-europe.com> wrote in message 
news:ei4qn3$s4q$1 digitaldaemon.com...
 When linking I get these error messages:
 #myprg.obj(myprg)

 __Class_3dbi4odbc12OdbcDatabase12OdbcDatabase
 #myprg.obj(myprg)

 _D3dbi4odbc12OdbcDatabase12OdbcDatabase5_ctorFZC3dbi


 If I don't want to create a new instance (OdbcDatabase x;) it's fine but
 cannot be used.

 What have I done wrong?
This usually happend when you've not added the source files to the command line.
Ok, I've ran into this problem before. But there's a *lot* of modules for this single one. How can I avoid the command line thing?
I wouldn't call it a "problem" as such: you have to tell the compiler which files to compile. However, Derek Parnell's Bud (nee Build) tool can make the task of compiling a lot less tedious. http://www.dsource.org/projects/build/wiki
Oct 30 2006
prev sibling next sibling parent reply Nahon <lburger hu.tesco-europe.com> writes:
I wouldn't call it a "problem" as such: you have to tell the compiler which
files to compile. However, Derek Parnell's Bud (nee Build) tool can make the
task of compiling a lot less tedious.
http://www.dsource.org/projects/build/wiki
Ok, it's a feature. :-) (I don't like it by the way... I think the compiler should automatically find the modules it has to compile: there are implicit commands for it.) But anything I do, I get this result: #c:\DMD\tarolas>bud_win_3.04 -full -names stock ws2_32.lib #Current Dir 'c:\DMD\stock\' #OPTLINK (R) for Win32 Release 7.50B1 #Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved #dbi\odbc\OdbcDatabase.obj(OdbcDatabase) #dbi\odbc\OdbcDatabase.obj(OdbcDatabase) #dbi\odbc\OdbcDatabase.obj(OdbcDatabase) #dbi\odbc\OdbcDatabase.obj(OdbcDatabase) #dbi\odbc\OdbcDatabase.obj(OdbcDatabase) #dbi\odbc\OdbcDatabase.obj(OdbcDatabase) #dbi\odbc\OdbcResult.obj(OdbcResult) It seems everything is imported but it does not compile/link.
Oct 30 2006
next sibling parent "JC" <johnch_atms hotmail.com> writes:
"Nahon" <lburger hu.tesco-europe.com> wrote in message 
news:ei50g3$12ec$1 digitaldaemon.com...
I wouldn't call it a "problem" as such: you have to tell the compiler 
which
files to compile. However, Derek Parnell's Bud (nee Build) tool can make 
the
task of compiling a lot less tedious.
http://www.dsource.org/projects/build/wiki
Ok, it's a feature. :-) (I don't like it by the way... I think the compiler should automatically find the modules it has to compile: there are implicit commands for it.)
I know what you're saying, but how is it supposed to know where your files are located?
 But anything I do, I get this result:

 #c:\DMD\tarolas>bud_win_3.04 -full -names stock ws2_32.lib
 #Current Dir 'c:\DMD\stock\'














 #OPTLINK (R) for Win32  Release 7.50B1
 #Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcResult.obj(OdbcResult)


 It seems everything is imported but it does not compile/link.
You haven't linked in the odbc import library. Specify "odbc32.lib" on the command line. Alternatively, in one of your modules, add the following: pragma(lib, "odbc32.lib"); An import library comes with the linker and utilities package from the website (http://ftp.digitalmars.com/dmc.zip). But I'm not sure if the one that version will work, because it's very old. If you have the latest Platform SDK, you can copy odbc32.lib from there into your dm\lib folder, and then run coffimplib (ftp://ftp.digitalmars.com/coffimplib.zip) on it to make it compatible with DMD.
Oct 30 2006
prev sibling parent James Pelcis <jpelcis gmail.com> writes:
Nahon wrote:
 #OPTLINK (R) for Win32  Release 7.50B1
 #Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcDatabase.obj(OdbcDatabase)

 #dbi\odbc\OdbcResult.obj(OdbcResult)

 
 It seems everything is imported but it does not compile/link.
That's a known problem that is caused by DMC not being shipped with up-to-date Windows libraries. To fix it, follow the instructions at http://www.dsource.org/projects/ddbi/wiki/ODBCSubproject. Hope you enjoy.
Oct 30 2006
prev sibling next sibling parent Brad Anderson <brad dsource.org> writes:
Nahon wrote:
 Hi.
 
 (Sadly) I have to connect to a *MSSQL* database in my program. I browsed the
 net quite a lot to find a D library (or sg.) that could do it. (I've found a
 connector form MySQL and a few others but not MSSQL.)
 Could someone help me about sending an URL for one or a module of own?
 
 Thank you.
I have wrappers for FreeTDS (http://www.freetds.org) that wrap its ctlib portion of code. They were generated with bdc.gen, and I was able to get a D program talking to MSSQL. However, it's a bit low-level, and I have plans on integrating it with the DDBI lib on dsource - http://www.dsource.org/projects/ddbi. Let me know if you want it in it's rough form. BA
Oct 30 2006
prev sibling next sibling parent reply Nahon <lburger hu.tesco-europe.com> writes:
I know what you're saying, but how is it supposed to know where your files
are located?
There are specified paths and a current directory... I think it should find them some of these places or send an error message. But for the last, not without searching. :)
You haven't linked in the odbc import library. Specify "odbc32.lib" on the
command line. Alternatively, in one of your modules, add the following:

    pragma(lib, "odbc32.lib");

An import library comes with the linker and utilities package from the
website (http://ftp.digitalmars.com/dmc.zip). But I'm not sure if the one
that version will work, because it's very old. If you have the latest
Platform SDK, you can copy odbc32.lib from there into your dm\lib folder,
and then run coffimplib (ftp://ftp.digitalmars.com/coffimplib.zip) on it to
make it compatible with DMD.
Thanks, I'll try it. :)
Oct 30 2006
parent "JC" <johnch_atms hotmail.com> writes:
"Nahon" <lburger hu.tesco-europe.com> wrote in message 
news:ei5509$17rk$1 digitaldaemon.com...
I know what you're saying, but how is it supposed to know where your 
files
are located?
There are specified paths and a current directory... I think it should find them some of these places or send an error message. But for the last, not without searching. :)
Perhaps the compiler could read the PATH environment variable, and then have an option to do a recursive search for .d files on that path. But that would compile everything it found, which often is not what you want.
Oct 30 2006
prev sibling parent Nahon <lburger hu.tesco-europe.com> writes:
JC wrote:

Perhaps the compiler could read the PATH environment variable, and
then have an option to do a recursive search for .d files on that
path. But that would compile everything it found, which often is not
what you want.
There are explicit information about what to import in the source files. I'm not a compiler programmer but I think that would be enough. Brad Anderson wrote:
I have wrappers for FreeTDS (http://www.freetds.org) that wrap its
ctlib portion of code.  They were generated with bdc.gen, and I was
able to get a D program talking to MSSQL.

However, it's a bit low-level, and I have plans on integrating it
with the DDBI lib on dsource - http://www.dsource.org/projects/ddbi.
Let me know if you want it in it's rough form.
Thank you, I'll try them as well. :)
Oct 30 2006