|
See here[^]. It doesn't seem to matter if you use AfxEndThread or simply return.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Member 4651741 wrote: my concern is, whether my thread occupy memory after closing the application
In the link provided by Code-o-mat, see the part about the CWinThread::m_bAutoDelete
member...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi there, i need some help here. I need to develop a standalone application using sqlite and c++...I have used sqlite browser to develop my database. So how does that get connected to c++??
Thank you.
|
|
|
|
|
Are you using MFC?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
what is MFC? I'm not sure..I'm using the normal c++ code. Don't think so it a MFC.
|
|
|
|
|
vanishaa wrote: what is MFC?
Microsoft Foundation Classes. A very nice wrapper around portions of the Windows API. Two classes of interest are CDatabase and CRecordset .
vanishaa wrote: I'm using the normal c++ code.
Then you'll need this.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Actually I'm doing a portable program which can be executed in any windows platform without any installation. Do you have any suggestions for portable database which can be connected to c++?? Currently I'm working on sqlite. But its kind of complicated.
Thank you.
|
|
|
|
|
vanishaa wrote: what is MFC?
M y F irst C program?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You #include <sqlite3.h> in your code, link with the sqlite library and use the SQLite C++ API[^] to access the database.
|
|
|
|
|
I think she is still blur how to to use the API.. show her a simple connection program plz... i don know about database so i not sure hw to help her.. :P
Thanks
|
|
|
|
|
what does a linker error means?? When i include the #include<sqlite3.h> header file alots of linker error messages is appearing..
|
|
|
|
|
That you forgot to link to the required library. It means that the code compiles fine (there are no syntax error in the code) but when the linker tries to assemble everything together, it can't find some specific functions, because you didn't specify the library from which they are coming from.
|
|
|
|
|
Look again at this article[^]. The "Working With SQLite" section gives you instructions for how to build an import library (.LIB file) for the SQLite 3 DLL. To use it, add a line like this to your main C++ file:
#pragma comment(lib, "sqlite.lib")
This will cause the linker to look in SQLite.lib for the SQLite functions.
|
|
|
|
|
>> #pragma comment(lib, "sqlite.lib")
Use a MAKE file to direct the linker to search for functions in that particular
library(.lib) is a more portable way I think, since this directive would be unknown with some compilers other than Microsoft's.
|
|
|
|
|
6Qing88 wrote: Use a MAKE file to direct the linker to search for functions in that particular library(.lib) is a more portable way I think
Hell, yeah - but given the OP was commenting like "what's a linker", I thought this was the simplest way to get their code to build
I wish all compilers had that directive - makes building so much easier. I love the way Boost uses it, with auto-selection to decide which of 4 or 6 library variants to link with
|
|
|
|
|
This page[^] gives an example of how to connect to a SQLite database with the C/C++ bindings.
This page[^] gives you more information about what's available in the C/C++ bindings for SQLite.
This page[^] has a downloadable e-book that shows you how to use SQLite with Visual C++ (see chapter 3 for instructions about how to build your program) [edit]This is a pay-for e-book - didn't notice that before- DOH![/edit].
And then there's this CodeProject article[^] (you know, CodeProject, the site you're asking this question on) that has a C++ wrapper for SQLite.
Google is your friend...
[edit]The CodeProject article tells you all you need to get started with SQLite. I see you've commented on the article already - if you can't make progress even after reading that article, I think you need to learn some basics about how to build C++ programs with third-party libraries...[/edit]
|
|
|
|
|
hi, i have tried to code the connection. It shows 1 error message. Don't really understand what is it..below is the code and error message.
Code:
// sparta1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "sqlite3.h"
#include <iostream>
#include "SQLAPI.h"
//#include <stdio.h>
//#include "Sl3API.h"
#pragma comment (lib,"sqlite3.lib")
int main(int argc, _TCHAR* argv[])
{
SAConnection con; //create connection object
SACommand cmd; // create command object
//&SAConnection::setClient;
con.setClient(SA_SQLite_Client);
void Connect(const SAString &sDBString, const SAString &sUserID, const SAString &sPasswords,SAClient_t eSAClient);
con.Connect("WORM.sqlite", "", "","SA_SQLite_Client");
cmd.setConnection(&con);
}
error message:
1>------ Build started: Project: sparta1, Configuration: Debug Win32 ------
1>Compiling...
1>sparta1.cpp
1>c:\users\vani\documents\visual studio 2005\projects\sparta1\sparta1\sparta1.cpp(29) : error C2664: 'SAConnection::Connect' : cannot convert parameter 4 from 'const char [17]' to 'SAClient_t'
1> There is no context in which this conversion is possible
1>Build log was saved at "file://c:\Users\Vani\Documents\Visual Studio 2005\Projects\sparta1\sparta1\Debug\BuildLog.htm"
1>sparta1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|
|
|
|
In
con.Connect("WORM.sqlite", "", "","SA_SQLite_Client");
should SA_SQLite_Client have quotes around it? That looks more like a variable or function name. As it's also the parameter that the compiler's complaining about, that may be the issue?
If it should be quoted - what are the constructors for SAClient_t ?
|
|
|
|
|
owh...i just noticed..the last parameter don't require quotes. But the error message is way to many after removing the quotes now.
// sparta1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "sqlite3.h"
#include <iostream>
#include "SQLAPI.h"
//#include <stdio.h>
//#include "Sl3API.h"
#pragma comment (lib,"sqlite3.lib")
int main(int argc, _TCHAR* argv[])
{
SAConnection con; //create connection object
SACommand cmd; // create command object
//&SAConnection::setClient;
con.setClient(SA_SQLite_Client);
//void Connect(const SAString &sDBString, const SAString &sUserID, const SAString &sPasswords,SAClient_t eSAClient);
con.Connect("WORM.sqlite", "1234", "1234",SA_SQLite_Client);
cmd.setConnection(&con);
}
error message:
1>------ Build started: Project: sparta1, Configuration: Debug Win32 ------
1>Compiling...
1>sparta1.cpp
1>Linking...
1> Creating library C:\Users\Vani\Documents\Visual Studio 2005\Projects\sparta1\Debug\sparta1.lib and object C:\Users\Vani\Documents\Visual Studio 2005\Projects\sparta1\Debug\sparta1.exp
1>sparta1.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall SAConnection::~SAConnection(void)" (??1SAConnection@@UAE@XZ) referenced in function _main
1>sparta1.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall SACommand::~SACommand(void)" (??1SACommand@@UAE@XZ) referenced in function _main
1>sparta1.obj : error LNK2019: unresolved external symbol "public: void __thiscall SACommand::setConnection(class SAConnection *)" (?setConnection@SACommand@@QAEXPAVSAConnection@@@Z) referenced in function _main
1>sparta1.obj : error LNK2019: unresolved external symbol "public: __thiscall SAString::~SAString(void)" (??1SAString@@QAE@XZ) referenced in function _main
1>sparta1.obj : error LNK2019: unresolved external symbol "public: void __thiscall SAConnection::Connect(class SAString const &,class SAString const &,class SAString const &,enum SAClient_t,void (__cdecl*)(class SAConnection &,enum SAConnectionHandlerType_t))" (?Connect@SAConnection@@QAEXABVSAString@@00W4SAClient_t@@P6AXAAV1@W4SAConnectionHandlerType_t@@@Z@Z) referenced in function _main
1>sparta1.obj : error LNK2019: unresolved external symbol "public: __thiscall SAString::SAString(char const *)" (??0SAString@@QAE@PBD@Z) referenced in function _main
1>sparta1.obj : error LNK2019: unresolved external symbol "public: void __thiscall SAConnection::setClient(enum SAClient_t)" (?setClient@SAConnection@@QAEXW4SAClient_t@@@Z) referenced in function _main
1>sparta1.obj : error LNK2019: unresolved external symbol "public: __thiscall SACommand::SACommand(void)" (??0SACommand@@QAE@XZ) referenced in function _main
1>sparta1.obj : error LNK2019: unresolved external symbol "public: __thiscall SAConnection::SAConnection(void)" (??0SAConnection@@QAE@XZ) referenced in function _main
1>C:\Users\Vani\Documents\Visual Studio 2005\Projects\sparta1\Debug\sparta1.exe : fatal error LNK1120: 9 unresolved externals
1>Build log was saved at "file://c:\Users\Vani\Documents\Visual Studio 2005\Projects\sparta1\sparta1\Debug\BuildLog.htm"
1>sparta1 - 10 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|
|
|
|
Linker error again - you need to link against whatever provides SAConnection, SAClient etc - would that be what you've included in SQLAPI.h?
Find the right library and tell the linker to look in it and you'll get rid of all those errors in one go!
|
|
|
|
|
yeap..the #include" SQLAPI.h" library contains the linker to SAConnection and SAClient.
|
|
|
|
|
the linker error is not resolved even after including the SQLAPI header file..
|
|
|
|
|
Noooo - you need to LINK against the SQLAPI LIBRARY file - you were already #includeing the header file.
|
|
|
|
|
Ohhh...Finally got it now...the linker errors have been resolved one shot. I have another question,
what does 'try' block starting on line '34' has no catch handlers means??not so familiar with this statement...
|
|
|
|
|
vanishaa wrote: what does 'try' block starting on line '34' has no catch handlers means
a) Which line 34? I haven't seen a try block anywhere.
b) A try block with no catch handlers means someone's forgotten to put catch handlers in...In fact, g++4.0.1 (the only C++ compiler I've got to hand) won't compile a try block with no handlers (what C++ compiler are you using? VC6?)
|
|
|
|