views:

385

answers:

3

I have transferred a Classic asp site running on windows server 2003 to windows server 2008 but suddenly the below code has stopped 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 the below error

Microsoft VBScript runtime error '800a01a8' 

Object required: 'Provider=SQLNCLI10.1'

This happens on the below line

response.write(cn.state)

Thanks Chris

A: 

You have that SQL Provider installed right?

You can put that function into a simple VBScript script to test without altering your pages any.

StingyJack
A: 

If I take opening of the connection out of the function and put in inline then there is no error and it works.

But my whole site works by using this function so a) I dont want to have to rewrite my code and b) I dont understand why this does not work when it used to.

This does not seem like it ever would have worked. (See Mike Henry's syntax suggestions) Maybe it used to "work" because you had "On Error Goto Next" on and errors were being hidden?Also, if your "whole site works by using this function" why would re-writing it be a problem? Why is it even "re-writing?" You change 2 lines of code and your whole site works again. :)
John Booty
+2  A: 

I see a few possible syntax issues with the code you posted:

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

Should it be updated to the following?

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

related questions