Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / CDaoDatabase DLL questions

Author
Message
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 26th Jan 2004 09:38 Edited at: 26th Jan 2004 09:40
Hey everyone,

I'm writing a DLL, and before I get too deep into the project, I'd like to have a few questions answered.

My DLL will let users retrieve recordsets and execute SQL commands to an Access database using the CDaoDatabase functionality of C++.

It keeps telling me

Quote: "'db' : undeclared identifier"


when I execute the following code...



This is obviously because I need the header file in there for CDaoDatabase (afxdao.h), so when I add it to the top of the code, I still get the same error. If I move the #include <afxdao.h> *below* the #include "stdafx.h", then it says

Quote: "WINDOWS.H already included. MFC apps must not #include <windows.h>"


*THEN*, I went into the StdAfx.h header file in my project, commented out #include <windows.h> just to see what would happen, and all hell broke loose:

Quote: "nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in DBACCESS2.obj
nafxcwd.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in DBACCESS2.obj; second definition ignored
Creating library Debug/DBACCESS2.lib and object Debug/DBACCESS2.exp
Debug/DBACCESS2.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe."


Can anyone see what I'm doing wrong? I've about had it up to the ceiling with this trouble! If you have any more questions of me, please ask.

I've made DLLs before, and I know how to get them compiled properly, etc.

Thanks

Ancient Chinese proverb: Man who runs behind car gets exhausted.

http://www.automatongames.com/
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 26th Jan 2004 10:07 Edited at: 26th Jan 2004 10:08
You probably need to #include the relevant header (probably begining with afx). CDatabase is #include "afxdb.h"


The place for all great plug-ins.
XP3000+,1Gb RAM,FX5600,1Mb ADSL,Router,.Net 2003 Pro & me
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 26th Jan 2004 20:13
Hmmm... that didn't work either. I still either get the link error as mentioned in my last post or the error saying WINDOWS.H was already included :-|

Ancient Chinese proverb: Man who runs behind car gets exhausted.

http://www.automatongames.com/
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 26th Jan 2004 21:55 Edited at: 26th Jan 2004 21:57
Yes, you dont use Windows.h if your using MFC - which the compiler thinks your doing.


The place for all great plug-ins.
XP3000+,1Gb RAM,FX5600,1Mb ADSL,Router,.Net 2003 Pro & me
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 26th Jan 2004 22:08
I know, but that's the problem of my original post. If I take out the #include <windows.h> line, I get the object link errors as mentioned in my first post.

Ancient Chinese proverb: Man who runs behind car gets exhausted.

http://www.automatongames.com/
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 26th Jan 2004 22:58
I think the problem is that your DLL is defined as a standard DLL, and not a MFC DLL - which is what my SQL plug-in is.


The place for all great plug-ins.
XP3000+,1Gb RAM,FX5600,1Mb ADSL,Router,.Net 2003 Pro & me
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Jan 2004 23:11
Why not just create a new project using the MFC Appwizard and insert your source code?

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 27th Jan 2004 20:13
Alright, cool, thanks for the tips. I used the DLL wizard like in the DBP tutorial, but that didn't work. I guess I'll try the Appwizard next, but I have no experience using the Appwizard to make a DLL

Ancient Chinese proverb: Man who runs behind car gets exhausted.

http://www.automatongames.com/
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 27th Jan 2004 20:32
Just select MFC DLL...


The place for all great plug-ins.
XP3000+,1Gb RAM,FX5600,1Mb ADSL,Router,.Net 2003 Pro & me
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 27th Jan 2004 21:51
TCA - Thanks, it compiles! Now I just have another question after searching the forums to no avail. The 3rd party docs aren't clear on how to make a string (in the string table) to have both a parameter *and* a return value.

My current string looks like this:

DB OPEN[%L%?DBOpenDatabase@@YAHPAD@Z

This should return an int (L), but I also want to send a string:

MYCOMMAND int DBOpenDatabase(LPSTR pDBName)

I'm probably blind, but thought I should ask the pros

Ancient Chinese proverb: Man who runs behind car gets exhausted.

http://www.automatongames.com/
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 27th Jan 2004 22:18
Figured it out--- I'm a fool. It *is* located in the 3rd party help near the bottom--- I have no idea how I missed that.

Ancient Chinese proverb: Man who runs behind car gets exhausted.

http://www.automatongames.com/
Ralen
21
Years of Service
User Offline
Joined: 22nd Jul 2003
Location:
Posted: 28th Jan 2004 07:31
For those people that don't understand what the answer was

DB OPEN[%L%?DBOpenDatabase@@YAHPAD@Z
^__1__^2^3^____________4___________^

1 is the name of the command in db
2 The [ symbol means your custom function will return a view
3 This area describes both the input and return variables.
- So if he wants to input a string this should look like
- DB OPEN[%SL$?DBOpenDataBase@@YAHPAD@Z
4 Is the decorated name of the function there is two very easy ways
to find out what this is. The first one is to simply open the DLL in notepad and look for it. There is another way. DBPro actually includes a batch file in the User Plug-ins directory just open the batch file and it because self explanetory. Basically supply a dll name and a output file. Then open the txt file the batch file generates.

It will display all of your functions in thier decorated forms. this is what you use to make your string table. Here is the secret and a major *TIP* When you make your string table its based to enter your functions in to the string table in the same order that you see them in this text file. Sometimes you get a function that doesn't work if you enter them in a differant order.

Sorry, just thought some information needed to be included :p

Ralen
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 28th Jan 2004 08:44
Oops, I guess I should've posted the answer I just found it strange that the String table requires the input and return variables listed right next to each other (i.e. LSLL), but it works!

Ancient Chinese proverb: Man who runs behind car gets exhausted.

http://www.automatongames.com/
Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 28th Jan 2004 08:59
I might add all that is quite clearly documented in the Third Party DLL help file.


"Computers are useless they can only give you answers."

Login to post a reply

Server time is: 2025-05-28 06:09:01
Your offset time is: 2025-05-28 06:09:01