Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Access 2007.
I am Getting exception "Unspecified Error" during execution.

C++
_ConnectionPtr m_pcon;
try {
  _bstr_t conStr = _T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"d:\\bank.mdb\"");
  hr = m_pcon->Open(conStr, L"",L"",adConnectUnspecified);
} catch(_com_error& ce) {
	MessageBox(ce.ErrorMessage()); 
 }


What I have tried:

1. Tried changing the connection string but won't help.
C++
_bstr_t conStr = _T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\bank.mdb");


2. File bank.mdb is present in D drive.
3. stdafx.h having the following additional statements for oledb connection
#include "atlbase.h"
#import "C:\Windows\winsxs\x86_microsoft-windows-m..ents-mdac-ado15-dll_31bf3856ad364e35_6.1.7601.22012_none_0ebfc67ce80861b4\msado15.dll" no_namespace rename("EOF", "ADOEOF")

Please suggest how to fix this issue.
Posted
Updated 11-Nov-16 23:10pm
v2
Comments
KarstenK 12-Nov-16 4:17am    
Are you sure, that the process has the rights to open the db. Try it in some temp dir.

1 solution

There is a semicolon missing at the end of your connect string.

Try this (using a wide string here to avoid conversions because the BSTR type uses wide strings internally):
_bstr_t conStr = L"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\bank.mdb;";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900