Article View: borland.public.cppbuilder.database.ado
Article #4702using TDatabase & Tquery in DLLs
From: Stephane Baillargeon
Date: Fri, 16 Nov 2001 01:56
Date: Fri, 16 Nov 2001 01:56
106 lines
4503 bytes
4503 bytes
I'm trying to create a function that accepts two integers, one for language
and the other is the components tag value. I create two variables called
dbDatabase and qryQuery of type TDatabase and TQuery respectively. The
Database is for login prompt use only and the Query is for the SQL
statements to execute. Now here's the problem: when I build the code for
the DLL, The linker returns me several errors. I have included the file
MEMMGR.LIB because I return AnsiStrings from my functions and the ODBCs are
correctly set so it's not those things that make it not work. Maybe I
forgot to #include<> a header file... Here are the errors:
Note : The source code follows the error messages.
1. [Linker Error] Unresolved external '__fastcall
Dbtables::TDatabase::SetDatabaseName(const System::AnsiString)' referenced
from C:\MES DOCUMENTS\C++ BUILDER 5 PROJECTS\GESTICO\CAPTIONS.OBJ
2. [Linker Error] Unresolved external '__fastcall
Dbtables::TDBDataSet::SetDatabaseName(const System::AnsiString)' referenced
from C:\MES DOCUMENTS\C++ BUILDER 5 PROJECTS\GESTICO\CAPTIONS.OBJ
3. [Linker Error] Unresolved external '__fastcall Db::TParams::GetItem(int)'
referenced from C:\MES DOCUMENTS\C++ BUILDER 5 PROJECTS\GESTICO\CAPTIONS.OBJ
4. [Linker Error] Unresolved external '__fastcall
Db::TParam::SetAsInteger(int)' referenced from C:\MES DOCUMENTS\C++ BUILDER
5 PROJECTS\GESTICO\CAPTIONS.OBJ
5. [Linker Error] Unresolved external '__fastcall
Dbtables::TQuery::Prepare()' referenced from C:\MES DOCUMENTS\C++ BUILDER 5
PROJECTS\GESTICO\CAPTIONS.OBJ
6. [Linker Error] Unresolved external '__fastcall Db::TDataSet::Open()'
referenced from C:\MES DOCUMENTS\C++ BUILDER 5 PROJECTS\GESTICO\CAPTIONS.OBJ
7. [Linker Error] Unresolved external '__fastcall
Db::TDataSet::FieldByName(const System::AnsiString)' referenced from C:\MES
DOCUMENTS\C++ BUILDER 5 PROJECTS\GESTICO\CAPTIONS.OBJ
8. [Linker Error] Unresolved external '__fastcall Db::TDataSet::Close()'
referenced from C:\MES DOCUMENTS\C++ BUILDER 5 PROJECTS\GESTICO\CAPTIONS.OBJ
----------------
Here's the code
----------------
//--------------------------------------------------------------------------
AnsiString GetCaptionWithTag(int intLang, int intTag)
{
AnsiString strCaption = "";
TQuery *qryQuery;
TDatabase *dbDatabase;
// Set dbParams
dbDatabase->DatabaseName = "Gestico";
dbDatabase->LoginPrompt = false;
// Set qryParams
qryQuery->DatabaseName = "Gestico";
// Make sure that query is closed before opening it again
qryQuery->Close();
// Set SQL select
qryQuery->SQL->Clear();
// Select field depending on language
switch(intLang)
{
case mintENGLISH:
{
qryQuery->SQL->Add("SELECT Cap_String_Eng AS Caption");
break;
}
case mintFRENCH:
{
qryQuery->SQL->Add("SELECT Cap_String_Fre AS Caption");
break;
}
default:;
}
qryQuery->SQL->Add("FROM Captions");
qryQuery->SQL->Add("WHERE Cap_Tag = :Tag");
qryQuery->Params->Items[0]->AsInteger = intTag;
// Prepare and open query
if(!qryQuery->Prepared)
{
qryQuery->UniDirectional = true;
qryQuery->Prepare();
}
// Open query
qryQuery->Open();
// Get caption and bind to component
if(!qryQuery->Eof)
strCaption = qryQuery->FieldByName("Caption")->AsString;
else
strCaption = "zError";
// Close query
qryQuery->Close();
return strCaption;
}
//--------------------------------------------------------------------------
Technical Details
Message-ID:
<3bf47300_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,98ddd7d28635dc59,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-11-15 18:01:05 PST From: "Stephane Baillargeon" <mbaillargeon@sympatico.ca> Newsgroups: borland.public.cppbuilder.database.ado Subject: using TDatabase & Tquery in DLLs Date: Thu, 15 Nov 2001 20:56:16 -0500 Lines: 108 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-Mimeole: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 65.94.174.215 Message-ID: <3bf47300_1@dnews> X-Trace: dnews 1005875968 65.94.174.215 (15 Nov 2001 17:59:28 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews