开发者

Getting error "Data provider could not be initialized" while connecting to backend

开发者 https://www.devze.com 2023-02-20 12:25 出处:网络
I have made an application in VB6 ( sybase 11 as backend ). Now when i am trying to login on user machine it is giving me below errror :

I have made an application in VB6 ( sybase 11 as backend ). Now when i am trying to login on user machine it is giving me below errror :

"Data provider could not be initialized." I AM USING BELOW CODE TO CONNECT TO BACKEND :

'/***** Procedure to establish connection to the back-end
On Error Resume Next

If pCon.State = 1 Then pCon.Close

pCon.Errors.Clear

pDSN = "TESTDSN"

开发者_开发问答pDatabase = "TESDB"

pCon.Open "Provider=MSDataShape;ODBC;Database=" & Trim(pDatabase) & ";UID="&           
Trim(  pUID) & ";PWD=" & pPWD & ";DSN=" & Trim(pDSN)

If pCon.Errors.Count > 0 Then

   interr = 0

   Do Until interr = pCon.Errors.Count

        MsgBox pCon.Errors.Item(interr).Description

        interr = interr + 1

    Loop

    fnCon = False

Else

    fnCon = True

End If

Thanks.


You need a connection string that defines both the Provider and the Data Provider:

Provider=MSDataShape;Data Provider=providername

OLEDB is not ODBC. If you insist on using an ODBC driver (or DSN, which is an old ODBC construct) you will have to specify the "thunk into ODBC" Provider named MSDASQL as your Data Provider.

People often use a shortcut syntax for connection strings that implies this "adapter" Provider. That won't work here.

As far as I know even Sybase offers a proper OLEDB Provider though. I have no idea why people insist on using ODBC and DSNs today (DSNs were replaced by UDLs a long time ago) unless they cannot obtain a proper Provider.

0

精彩评论

暂无评论...
验证码 换一张
取 消