Below is the code I am attempting to use. It works fine on
the development machine - but once I export to another machine - I get an error saying this program has ended abnormally and you should contact the vendor.
I am thinking its because the "Provider=Microsoft.Jet.OLEBD.4.0" is not on the machine I am attempting to use this program. Is there a solution for this ?
Thanks.
Merlin Vilhauer
=================== code =========
void ExecuteX()
{
// SELECT SQL
_bstr_t strSQL("SELECT * FROM ReceivedData");
//CONNECTION_STRING
_bstr_t strCnn("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\tmp\\090824M.BWS;");
// Define ADO object pointers. Initialize pointers on define.
// These are in the ADODB:: namespace.
_ConnectionPtr pConnection = NULL;
_CommandPtr pCmdChange = NULL;
_RecordsetPtr pRstTitles = NULL;
try {
// Open connection.
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
pConnection->Open (strCnn, "", "", adConnectUnspecified);
// Create command object.
TESTHR(pCmdChange.CreateInstance(__uuidof(Command)));
pCmdChange->ActiveConnection = pConnection;
// Open titles table, casting Connection pointer to an
// IDispatch type so converted to correct type of variant.
TESTHR(pRstTitles.CreateInstance(__uuidof(Recordset)));
pRstTitles->Open (strSQL, _variant_t((IDispatch *) pConnection, true),
adOpenStatic, adLockOptimistic, adCmdText);
// Print report of original data.
// Call function to print loop recordset contents.
PrintOutput(pRstTitles);
}
catch (_com_error &e) {
PrintProviderError(pConnection);
PrintComError(e);
}
// Clean up objects before exit.
if (pRstTitles)
if (pRstTitles->State == adStateOpen)
pRstTitles->Close();
if (pConnection)
if (pConnection->State == adStateOpen)
pConnection->Close();
}
=============== code ======================