I'm having difficulty figuring out how to set up the parameters for doing an Open with the CDataSource class.
My database is named "MyDatabase".
It's an OLE DB type of database.
The Provider is Microsoft OLE DB Provider for SQL Server, so I think that means using the string "SQLOLEDB" as a parameter to the Open method.
My Server Name is "MyServer".
I can successully open it up using just:
which simply prompts me via a dialog for all the various information.Code:CDataSource theDatabase; hResult = theDatabase.Open();
But I need to do it programmatically.
I think I need to set up a CDBPropSet with something like:
and then open it with something like:Code:CDBPropSet dbPropertySet(DBPROPSET_DBINIT); dbPropertySet.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false); dbPropertySet.AddProperty(DBPROP_INIT_DATASOURCE, "RogesPlaceOLEDB"); dbPropertySet.AddProperty(DBPROP_INIT_PROMPT, (short)DBPROMPT_NOPROMPT); dbPropertySet.AddProperty(DBPROP_INIT_LCID, (long)2057); // NOTE: this came from page 159 of the Visual C++ 6 DATABASE PROGRAMMING TUTORIAL book
but it always fails.Code:HRESULT hResult; hResult = m_Database.Open(_T("SQLOLEDB"),&dbPropertySet);
I'm obviously not passing in the name of the server (i.e. "MyServer") anywhere, but I can't figure out where to do that. And I suspect that some of the rest is also not quite right.
Any help would be greatly appreciated.




Reply With Quote