Databse & C++?
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
Databse & C++?
Anyone know of a good library for any kind of database and C++? Rather than using IrrNet for logins and such I think this would be more affective and reduce in-game lag for those actually playing at the time.
Well, I tried Interbase, Firebird but both need a server installation /easy/.
Several days ago I found SQLite and tested it with C++Builder.
http://www.sqlite.org/
No installs are necessary, server is implemented like just one dll. Also sources are available too. Google it, also you can download SQLite3 manager LITE for database design:
http://www.filedepot.eu/
Several days ago I found SQLite and tested it with C++Builder.
http://www.sqlite.org/
No installs are necessary, server is implemented like just one dll. Also sources are available too. Google it, also you can download SQLite3 manager LITE for database design:
http://www.filedepot.eu/
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
Hi
Sorry i am not sure if this is what you are looking for,
I used MySQL linked to ODBC using windows.h API
But the software (C++) run on a intranet and in this case on the server.
i do not know if you can link trhou the internet via ODBC .
You probably would need to make a client server using this way
if i am not wrong MySql has dll to link C/C++ to the database
but in this way you would have to pay as the GPL has limitation to link DLL staticly to your code, so i used ODBC.
Cheers
Sorry i am not sure if this is what you are looking for,
I used MySQL linked to ODBC using windows.h API
But the software (C++) run on a intranet and in this case on the server.
i do not know if you can link trhou the internet via ODBC .
You probably would need to make a client server using this way
if i am not wrong MySql has dll to link C/C++ to the database
but in this way you would have to pay as the GPL has limitation to link DLL staticly to your code, so i used ODBC.
Cheers
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
No you have not to pay to use your database but to use "my sql"
But i get information +- a year ago as i needed for a commercial product.
Maybe something is changed.
then if you use through ODBC it 's totally free also for commercial products (always information of 1 year ago).
to access to MySql table via ODBC is not defficult you can find a lot info on the internet or if you decide in this way and need help let me know.
then you probably need to have access via the internet, could i suggest using sokets?
or PHP with your webserver
or reading the forum i saw that tere are library to easy use network
but i never tried them
bye
But i get information +- a year ago as i needed for a commercial product.
Maybe something is changed.
then if you use through ODBC it 's totally free also for commercial products (always information of 1 year ago).
to access to MySql table via ODBC is not defficult you can find a lot info on the internet or if you decide in this way and need help let me know.
then you probably need to have access via the internet, could i suggest using sokets?
or PHP with your webserver
or reading the forum i saw that tere are library to easy use network
but i never tried them
bye
-
- Posts: 1029
- Joined: Thu Apr 06, 2006 12:45 am
- Location: Tennesee, USA
- Contact:
Well so for the ODBC friends and cultists, i give some more info about it
- it 's a Microsoftw "library" to access database but i remembere that there was something also for Linux
- It is slow for uge number of data (tousands records for seconds ) so for some kind of work it better to use direct access to the database
- it is only a link so you need a database but you can also use a text file as database
- link a database you have to :
configure the ODBC in panell control, on the intranet server or on local computer , mainly give a name, the directory where your DB is located, and select a driver for the specified Database.
- call windows API to deal with ODBC (there are also library to do this )
but to trouble a bit more it is suggested to use windows API Here there are some:
///Initialize the job
// Allocate Environment
sr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hOdbcEnv);
// Set the App's ODBC Version
sr = SQLSetEnvAttr(hOdbcEnv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
// Allocate Connection
sr = SQLAllocHandle(SQL_HANDLE_DBC, hOdbcEnv, &hDbConn);
// Set Connect Timeout and other parameters
sr = SQLSetConnectAttr(hDbConn, SQL_ATTR_LOGIN_TIMEOUT, (void*)20, 0);
sr = SQLSetConnectAttr(hDbConn, SQL_ATTR_ACCESS_MODE, SQL_MODE_READ_WRITE, 0);
// Connect to Data Source
sr = SQLConnect(hDbConn, (UCHAR *)sDSN, SQL_NTS,(UCHAR *)szUID, SQL_NTS,(UCHAR *) szAuthStr, SQL_NTS);
once configurate the link and connected to database , we can enjoy ourselves
Sending query
// Allocate new Statement Handle based on previous connection
sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
sr = SQLExecDirect(hstmt, (SQLCHAR *) strSQL, SQL_NTS);
..................
// and free the statment after execution
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
Bind data from a previous query to read data
sr = SQLBindCol( hstmt, (SQLUSMALLINT)pColNumber, SQL_C_CHAR,(SQLPOINTER) cPointer ,ipMaxLen, & ValueLenOrInd);
and read then
sr = SQLFetch(hstmt) ;
Kill'em all
//Disconnect from database
SQLDisconnect(hDbConn);
//Free connection
SQLFreeHandle(SQL_HANDLE_DBC, hDbConn);
//Free environment
SQLFreeHandle(SQL_HANDLE_ENV, hOdbcEnv);
Hope it could be useful
- it 's a Microsoftw "library" to access database but i remembere that there was something also for Linux
- It is slow for uge number of data (tousands records for seconds ) so for some kind of work it better to use direct access to the database
- it is only a link so you need a database but you can also use a text file as database
- link a database you have to :
configure the ODBC in panell control, on the intranet server or on local computer , mainly give a name, the directory where your DB is located, and select a driver for the specified Database.
- call windows API to deal with ODBC (there are also library to do this )
but to trouble a bit more it is suggested to use windows API Here there are some:
///Initialize the job
// Allocate Environment
sr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hOdbcEnv);
// Set the App's ODBC Version
sr = SQLSetEnvAttr(hOdbcEnv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
// Allocate Connection
sr = SQLAllocHandle(SQL_HANDLE_DBC, hOdbcEnv, &hDbConn);
// Set Connect Timeout and other parameters
sr = SQLSetConnectAttr(hDbConn, SQL_ATTR_LOGIN_TIMEOUT, (void*)20, 0);
sr = SQLSetConnectAttr(hDbConn, SQL_ATTR_ACCESS_MODE, SQL_MODE_READ_WRITE, 0);
// Connect to Data Source
sr = SQLConnect(hDbConn, (UCHAR *)sDSN, SQL_NTS,(UCHAR *)szUID, SQL_NTS,(UCHAR *) szAuthStr, SQL_NTS);
once configurate the link and connected to database , we can enjoy ourselves
Sending query
// Allocate new Statement Handle based on previous connection
sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
sr = SQLExecDirect(hstmt, (SQLCHAR *) strSQL, SQL_NTS);
..................
// and free the statment after execution
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
Bind data from a previous query to read data
sr = SQLBindCol( hstmt, (SQLUSMALLINT)pColNumber, SQL_C_CHAR,(SQLPOINTER) cPointer ,ipMaxLen, & ValueLenOrInd);
and read then
sr = SQLFetch(hstmt) ;
Kill'em all
//Disconnect from database
SQLDisconnect(hDbConn);
//Free connection
SQLFreeHandle(SQL_HANDLE_DBC, hDbConn);
//Free environment
SQLFreeHandle(SQL_HANDLE_ENV, hOdbcEnv);
Hope it could be useful
hi,
few months ago i presented the ETNA lib topic here.
At this time i thought it was the best way for me to connect on a database. But i'd like to know if i shouldn't use another library (like ODBC for example). What do you think about it ?
PS: i read that some servers ( the free.fr servers for example) doesn't accept external request. is it true ?
few months ago i presented the ETNA lib topic here.
At this time i thought it was the best way for me to connect on a database. But i'd like to know if i shouldn't use another library (like ODBC for example). What do you think about it ?
PS: i read that some servers ( the free.fr servers for example) doesn't accept external request. is it true ?
KIC : frateamkic.info
(i'm frensh so scuse me for my english ...)
(i'm frensh so scuse me for my english ...)