Open classic ASP DB function not working

I migrated an asp classic asp site running on Windows Server 2003 to a Windows Server 2008, but suddenly this code stops working.

Const connStr_FC08 = "Provider=SQLNCLI10;Server=DS-47500;Database=TestDB;Uid=TestLogin;Pwd=test;Network=dbmssocn;"

Function connDB(OpenDB)
    DIM conn
    SET conn = Server.CreateObject("ADODB.Connection")
    conn.open = connStr_FC08
    If OpenDB = "Y" Then conn.open
    connDB = conn
End Function

dim cn, cmd
cn = connDB("Y")
response.Write(cn.state)

      

This returns below error

Microsoft VBScript runtime error '800a01a8' 

Object required: 'Provider=SQLNCLI10.1'

      

This happens in the line below

response.write(cn.state)

      

Thank you, Chris

0


source to share


3 answers


I see several possible syntax problems with the code you posted:

    ...
    conn.open = connStr_FC08
    ...
    connDB = conn
...
cn = connDB("Y")

      



Should it be updated to the next one?

    ...
    conn.ConnectionString = connStr_FC08
    ...
    Set connDB = conn
...
Set cn = connDB("Y")

      

+2


source


Do you have the correct SQL provider installed?



You can put this function in a simple VBScript script for testing without changing your pages.

0


source


If I open the connection from a function and insert inline then there is no error and it works.

But my whole site works using this feature, so: a) I don't want to rewrite my code and b) I don't understand why this doesn't work when he is used to it.

0


source







All Articles