README.md
December 4, 2022 ยท View on GitHub
Description
To open MS Access or Ms SQL server database using C/C++ or VC++
More Info
Change the name of the database to any database and place it in the same directory as the .exe. You shoul also change the SQL to your particular database. You may change the connect string to connect to MS SQL Server.
Shows some recordsets
Great
| Submitted On | |
| By | Mokarrabin A Rahman |
| Level | Beginner |
| User Rating | 4.6 (51 globes from 11 users) |
| Compatibility | C, C++ (general), Microsoft Visual C++ |
| Category | Databases |
| World | C / C++ |
| Archive File |
Source Code
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
// This code comes from : www.geocities.com/mokarrabin
#include <stdio.h>
#include <iostream.h>
void main(void)
{
CoInitialize(NULL);
try
{
_RecordsetPtr pRst("ADODB.Recordset");
// Connection String
_bstr_t strCnn("DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;DBQ=GBOOK.mdb");
// Open table
pRst->Open("SELECT * FROM ProductService where ProductService like '%samir%';", strCnn, adOpenStatic, adLockReadOnly, adCmdText);
pRst->MoveFirst();
while (!pRst->EndOfFile) {
cout<<(char*) ((_bstr_t) pRst->GetFields()->GetItem("ProductService")->GetValue())<<endl;
pRst->MoveNext();
}
pRst->Close();
}
catch (_com_error &e)
{
cout<<(char*) e.Description();
}
::CoUninitialize();
}