Can't connect using OleDB provider SQLOLEDB

Can't connect using OleDB provider SQLOLEDB

Post by Bart » Fri, 18 Jun 1999 04:00:00



I've written a program using OLEDB (vc++6 sp3) that retrieves data from
my SQL Server 7.0 DB. I use the OLEDB for ODBC provider (MSDASQL) , but
now I want to use the native OleDB provider for SQL server(SQLOLEDB).
However I can't connect using following code:

  CDBPropSet dbinit(DBPROPSET_DBINIT);

  dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR("joe"));
  dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("joe"));
  dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
  dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("MyDataBase"));
  dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
  dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);

  hr = db.Open(_T("SQLOLEDB"), &dbinit);

What heve I forgotten?

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

Can't connect using OleDB provider SQLOLEDB

Post by Bob Beauchemi » Fri, 18 Jun 1999 04:00:00


    Hi Bart,

Is "MyDataBase" the name of your database or your SQLServer? It should be
the name of your SQL Server (usually a machine name). Using OLE DB provider
for ODBC, DBPROP_INIT_DATASOURCE points to an ODBC DSN, which won't work
with SQLOLEDB.

Bob Beauchemin


Quote:> I've written a program using OLEDB (vc++6 sp3) that retrieves data from
> my SQL Server 7.0 DB. I use the OLEDB for ODBC provider (MSDASQL) , but
> now I want to use the native OleDB provider for SQL server(SQLOLEDB).
> However I can't connect using following code:

>   CDBPropSet dbinit(DBPROPSET_DBINIT);

>   dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR("joe"));
>   dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("joe"));
>   dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
>   dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("MyDataBase"));
>   dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
>   dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);

>   hr = db.Open(_T("SQLOLEDB"), &dbinit);

> What heve I forgotten?

> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


 
 
 

1. OpenQuery using OLE DB provider 'SQLOLEDB'

Hi,

I'm trying to populate data in one SQL Server db (TARGET)
using data from another SQL Server (SOURCE).  In the
TARGET server I set up SOURCE server as a linked server, I
have DTC service running.

Here is the code I'm trying to execute (it worked once,
then does work the rest of the time, I'm sure there is no
syntax error):

-- specify database name in TARGET db
Use Guardian

-- declare and set value for variables








-- begin populating reference tables
BEGIN TRANSACTION
print 'working with ApplicationClass table'
-- insert new reference data from BOI1160
INSERT INTO dbo.ApplicationClass
(ApplicationClassID, ApplicationClassName,
ApplicationClassDescription, ActiveFlag)
SELECT ApplicationClassID, ApplicationClassName,

FROM OPENQUERY(BOI1160, 'select * from
Guardian.dbo.ApplicationClass')
-- commit transaction
COMMIT

Here is the error I kept getting:
Server: Msg 7391, Level 16, State 1, Line 33
The operation could not be performed because the OLE DB
provider 'SQLOLEDB' was unable to begin a distributed
transaction.
[OLE/DB provider returned message: New transaction cannot
enlist in the specified transaction coordinator. ]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB'
ITransactionJoin::JoinTransaction returned 0x8004d00a].

I tried shutting down the DTC service, TARGET server,
deleting then adding the linked server, etc, with no
luck.  This worked once yesterday, then refused to work
afterwards.

Please help....

2. Progress Programmer/Analyst/Administrator

3. Only sa Connects using SQLOLEDB provider

4. Approach 3.0 summaries

5. Can't retrieve temp table rows using SQLOLEDB provider

6. Sql ServerAgent Job - Priorities

7. Couldn't create a linked server to INFORMIX using Informix OleDb provider

8. Bug in ADO Recordset.Filter?

9. Microsoft OLEDB provider or Oracle OLEDB provider

10. Connect by OLEDB Provider for SQL Server to remote SS7DB connected by ISDN-Router

11. provider=SQLOLEDB doesn't seem to work with ADO

12. Can't connect to Oracle using MSDAORA OLE DB provider