locked
Error from ADO connection string to SQL Server 2008 RRS feed

  • Question


  • I have an ADO connection string that works fine for Sql Server 2000/2005 but does not work for Sql Server 2008 for provider=sqloledb. Has the provider changed in Sql Server 2008?

    strConnect = "Server=" & strServer _

                                        & ";user ID=" & strUserID _

                                        & ";pwd=" & strPassword _

                                        & ";database=" & strDatabase _

                                        & ";provider=sqloledb"

    Thanks,
    Monday, March 30, 2009 4:28 PM

Answers

  • Hello Laral,
    You know that ADO can connect SQL Server by two kinds of OLEDB provider. One is sqloledb and the other is msdasql. They have different connection string. Your connection string is  for msdasql.
    If you want to connect SQLServer by sqloledb, please try connection string by the below syntax.
    oConn.Open "Provider=sqloledb;" & _
               "Data Source=myServerName;" & _
               "Initial Catalog=myDatabaseName;" & _
               "User Id=myUsername;" & _
               "Password=myPassword"

    • Proposed as answer by Chao SUEditor Tuesday, March 31, 2009 3:21 AM
    • Marked as answer by laral Tuesday, March 31, 2009 11:21 PM
    Monday, March 30, 2009 7:26 PM
    Answerer