Re: C++ support for ADO
- From: Neil B <NeilB@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 28 Feb 2007 14:03:05 -0800
Okay, I blanked out the User Id and Password Parameters from the OPEN.
I've added them in the connection string because the database itself is
password protected. So the open looks like this:
hr=connection->Open(L"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Finances
2006;UID=admin;PWD=049426115040;", L"", L"", ADODB::adConnectUnspecified);
this resulted in the following error:
"Could not find installable ISAM."
Any idea what causes this??
Thanks, Neil
PS: Do you have to run SQLConfigDataSource(....) before doing the open?
"Bob Barrows [MVP]" wrote:
Neil B wrote:.
Thanks for the overview, it was enlightening.
In answer to your question I'm interested in ADO not the ADO.net.
I have the following code compiled and running up to the OPEN
Connection:
//*************************************************
bool CDataBase::Open(CString userName, CString password, CString
cnnStr) //*************************************************
{
HRESULT hr;
_bstr_t errorMsg;
_bstr_t _userName, _password, _cnnStr;
_userName=LPCTSTR(userName);
_password=LPCTSTR(password);
_cnnStr=LPCTSTR(cnnStr);
// Create a connection object
ADODB::_ConnectionPtr connection;
hr = connection.CreateInstance(__uuidof(ADODB::Connection));
// Create a record set object
ADODB::_RecordsetPtr recordset;
hr = recordset.CreateInstance(__uuidof(ADODB::Recordset));
// Open a connection to a data base
connection->CursorLocation = ADODB::adUseClient;
try {hr=connection->Open(L"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Finances 2006;", L"admin", L"049846234640",
ADODB::adConnectUnspecified); }
catch(_com_error &e)
{
// Handle errors
errorMsg=e.Description();
return 0;
}
At this point I get the errorMsg of :
"Cannot start your application. The workgroup information file is
missing or opened exclusively by another user."
This is a Jet-specific error. Unless your database file is protected
using workgroup security (which is set up within the Access
environment), you must not pass a username and password to the engine in
the call to the Open method*. Doing so causes it to look for the
workgroup security file associated with the database to authenticate the
supplied username and password. If your database IS protected either by
password-only or by workgroup security, then see here for how the
connection string should be constructed:
http://www.carlprothman.net/Default.aspx?tabid=81
Not familiar with workgroup information file.
Is this related to the Initial Catalog command?
If so how do you set it up? Or where do you find it?
It is not set up unless your database needs workgroup security. One uses
Access to set up workgroup security, during the course of which, a file
with an extension of .mda is created. You will need to look at Access
online help for more information on this.
Where can I get the class info on ADODB::_ConnectionPtr andTake a look at
ADODB::_RecordsetPtr ?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmscadoapireference.asp.
The Connection and Recordset objects pretty much correspond to the lower
class objects you are asking about.
And how can I convert _bstr_t to a CString?No clue. That's a C++ question, not ADO, AFAICS.
*Actually, it is rarely necessary to use the username and password
arguments in the Open method, especially when using the native OLE DB
provider as you are doing. Authentication is done in the connection
string itself. The Open method arguments are typically only used when
supplying an ODBC DSN in the source argument.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
- References:
- Re: C++ support for ADO
- From: Ralph
- Re: C++ support for ADO
- From: Neil B
- Re: C++ support for ADO
- From: Bob Barrows [MVP]
- Re: C++ support for ADO
- Prev by Date: Re: C++ support for ADO
- Previous by thread: Re: C++ support for ADO
- Index(es):
Relevant Pages
|
|