|
-
August 22nd, 2005, 05:50 AM
#1
database handling using API in VC++
Hi ,,
Cud Some one tell me how can i handle database in Visual C++ by means of API Functions..
Thanx in Advance...
-
August 22nd, 2005, 06:31 AM
#2
Re: database handling using API in VC++
You could use ODBC drivers.
See this simple code sample:
Code:
CDatabase db ;
BOOL bSuccess;
TRY
{
CString strDriver = "SQL Server";
CString strConnect;
bSuccess = db.OpenEx( _T("DRIVER=MySQL ODBC 3.51 Driver;DATABASE=test") );
if( bSuccess)
{
//db.ExecuteSQL( _T("INSERT INTO TABLE1 VALUES(1, \"test string\")") );
CRecordset query( &db );
query.Open( CRecordset::snapshot,
_T("SELECT * FROM TABLE1") );
while(query.IsEOF() == 0)
{
CDBVariant value;
query.GetFieldValue(_T("test"), value);
query.MoveNext();
}
bSuccess = FALSE;
}
}CATCH_ALL ( ex)
{
TCHAR pszmsg[256];
ex->GetErrorMessage(pszmsg, 256);
}
END_CATCH_ALL
You will need the propper ODBC Driver for your Database System. MSSQL and MSAccess Drivers are shipped with Windows as far as I know. MySQL Drivers are available for download...
-
August 22nd, 2005, 06:34 AM
#3
Re: database handling using API in VC++
For MySQL you can also use the library which you can download from the developer zone of http://www.mysql.org
-
August 24th, 2005, 06:19 AM
#4
Re: database handling using API in VC++
 Originally Posted by C.Schlue
You could use ODBC drivers.
ODBC is antiquated. Depending on what he's doing, new development should usually rely on ADO which is just a high-level (COM) wrapper around OLE/DB (also COM). He should check out the #import statement in VC++ using the OLE/DB provider for his partiular DB. OTOH, ADO.NET should be explored if he's working in that environment instead (.NET). Both subjects are widely documented online.
-
August 26th, 2005, 08:25 AM
#5
Re: database handling using API in VC++
 Originally Posted by Revolution
Hi ,,
Cud Some one tell me how can i handle database in Visual C++ by means of API Functions..
Thanx in Advance...
From another viewpoint, how you handle databases in Visual C++ depend on the API functions provided by databases such as MySQL, Firebird Server, PostgreSQL, and others.
The API functions, usually C API functions, provided by these databases allow direct access without having to go through ODBC.
There are also C++ libraries that wrap the C API functions. For example, there is MySQL++ for MySQL and IBPP, a C++ client interface for
Firebird Server & InterBase.
Best Regards,
Yeoh
--
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|