[Qt-interest] using an application's databse connection insideaDLL (on win32)

Scott Aron Bloom Scott.Bloom at sabgroup.com
Fri Mar 6 17:12:51 CET 2009


> > What have you tried? I have used a "setDatabase" function into a DLL
and
> > it worked..
> 
> I already plan to implement such a "setDatabase" function as well, but
only
> as a last resort.
> 
> >  However, I have not tried to use the "global" database, but
> > I would guess it would work...
> > Have you tried it? What happened?
> 
> In the concerning DLL, the qt-internal list ob named database
connections
> (QSqlDatabase::connectionNames()) is always empty and
QSqlDatabase::database()
> always returns an invalid database, no matter how many
> connections got opened and registered in the main application. I guess
that
> on windows a DLL has its own personal protected memory region and
therefore
> cannot access the main application's global objects, such a that
global
> database connections list. But I mainly work with linux and do not
have
> enough knowledge of windows internals to estimate this. If I am right,
> then this would render that qt-named-connections paradigm unusable
from
> inside a DLL. On the other hand, the code of QSqlDatabase does itself
reside
> in a DLL.
> 
> --
> 
> greetings ... Adolf Berthold
Without a reproducible codebase to work on, its hard to give much
advice...

However, what type of DLL linking are you using?  Are you statically
binding or dynamically binding?

Create a simple couple of projects and post them and maybe we can help.

Scott




More information about the Qt-interest-old mailing list