[Qt-interest] Using DAO via ActiveX to manipulate MS Access database structure?
Andre Somers
andre at familiesomers.nl
Tue Apr 6 13:13:45 CEST 2010
On 1-4-2010 17:34, Andre Somers wrote:
> Hi,
>
> I am trying to manipulate a MS access database's structure.
> Unfortunately, the ODBC interface has limited capabilities. For
> instance, it does not support the CREATE VIEW statement*. So, I
> decided to try to manipulate my database using ActiveX. I have managed
> to create a new database file, but I have not managed to open an
> existing one. I get a segfault inside qaxbase.cpp (line 2858, to be
> exact) if I try to operate on the QAxObject returned from the call to
> open the database. My code looks like this:
>
> QTextBrowser* tb = new QTextBrowser();
> tb->show();
>
> QAxObject *accDbE = new
> QAxObject("{00000100-0000-0010-8000-00AA006D2EA4}", this); //DAO 3.6
> QAxObject *accDb = accDbE->querySubObject("OpenDatabase(QString,
> QVariant, QVariant, QVariant)",
> QString("C:\\Documents
> and Settings\\andre\\Desktop\\tool\\ascor2009.mdb"),
> 0,
> false,
> QString("") );
>
> if (!accDb) {
> qDebug() << "Error connecting to database, no database object
> received";
> return;
> }
> if (accDb->isNull()) {
> qDebug() << "Null wrapper returned";
> return;
> }
>
> //tb->setHtml( accDb->generateDocumentation() ); //This call causes
> a segfault
>
> params.clear();
> params << "TestQuery";
> params << "SELECT * FROM Articles";
>
>
> //this call also causes a segfault
> QAxObject *query =
> accDb->querySubObject("CreateQueryDef(QString, QString)",
> QString("TestQuery"),
> QString("SELECT * FROM
> Articles"));
>
>
>
>
> Using ActiveX from Qt is uncharted terrain for me. I tried to do the
> same trick from an Excel VBA macro (open a database, and create a new
> query), and that worked just fine. Could anyone provide some pointers
> on how to do this kind of thing?
>
> André
>
> *) That is, it does, if you add a connection flag, but those don't
> come up as queries in Access, and that was the goal to begin with
Any suggestions?
André
More information about the Qt-interest-old
mailing list