Hello I am having a problem... okay in the following code there is a function called CoInitialize. this function is giving me an error saying it is undefined.
okay i know it has something to do with the dll and i think it has something to do with my compiler...
is there something equal to CoInitialize in C++ Borland 6?
Any help would be great!
Code://**************************************
//
// Name: Access MDB
// Description:To open MS Access or Ms S
// QL server database using C/C++ or VC++
// By: Mokarrabin A Rahman
//
// Returns:Shows some recordsets
//
// Assumes:Change the name of the databa
// se to any database and place it in the s
// ame directory as the .exe. You shoul als
// o change the SQL to your particular data
// base. You may change the connect string
// to connect to MS SQL Server.
//
// Side Effects:Great
//
//This code is copyrighted and has// limited warranties.Please see http://
// www.Planet-Source-Code.com/xq/ASP/txtCod
// eId.1371/lngWId.3/qx/vb/scripts/ShowCode
// .htm//for details.//**************************************
//
#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();
}