Il database ha un solo campo di tipo testo chiamato "nome" e una
sola tabella chiamata "tabella".
Codice
Il programma c++ è il seguente
#import “c:windowsSystemmsado15.dll” no_namespace rename(”EOF”,”EndOfFile”) #include<stdio.h> #include<iostream.h> void main() { CoInitialize(NULL); try { _RecordsetPtr pRst(”ADODB.Recordset”); _bstr_t strCnn(”DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;DBQ=c:\db.mdb”); pRst->Open(”SELECT * FROM tabella”,strCnn,adOpenStatic,adLockReadOnly,adCmdText); pRst->MoveFirst(); while(!pRst->EndOfFile){ cout<<(char*) ((_bstr_t) pRst->GetFields()->GetItem("nome")->GetValue())<<endl; pRst->MoveNext(); } pRst->Close(); } catch(_com_error &e) { cout<<(char *) e.Description(); } ::CoUninitialize(); cout<<”"<<endl; cout<<”"<<endl; cout<<”Done”<<endl; }
Aggiungi un commento