0

似乎在这里尝试了一切以使其正常工作,但是对于我可以在互联网领域找到的几乎每次迭代的无 dsn 连接字符串,我都会收到“不支持关键字”错误,下面显示了两个。

Public cnSystem As New SqlClient.SqlConnection

Public Sub ConnectToSQL()

    Dim sConnectionString As String
    Dim sServer As String

    Try
        'Always connect to production server to get startup environment variables
        If gbIsProduction Then
            If gsProductionServer = "" Then
                sServer = "xxxxx-SQL"
            Else : sServer = gsProductionServer
            End If
        Else : sServer = gsDevelopmentServer
        End If
        //Doesn't work
        sConnectionString = "Network Library=DBMSSOCN;Data Source=xxxxx-SQL,1433;Inital Catalog=xxxxx;User ID=sa;Password=xxxxx;"
        //Doesn't work
        sConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;UserId=sa;Initial Catalog=xxxxx;Data Source=xxxxx-SQL;Password=xxxxx;"  
        cnSystem.ConnectionString = sConnectionString
        cnSystem.Open()
        cmdSystem.Connection = cnSystem
    Catch ex As Exception
        RaiseError("", "modGeneral." & System.Reflection.MethodBase.GetCurrentMethod().Name, Err.Number, Err.Description)
    End Try

End Sub

关于使用我正在使用的数据对象与 SQL 服务器进行无 DSN 连接的正确连接字符串是什么的任何想法?

谢谢!

4

2 回答 2

2

虽然不是确切的答案,但这个网站一直在帮助我:

http://www.connectionstrings.com/

此外,使用 System.Data.SQLClient 时,您不必指定提供程序,我相信您会收到收到的错误。删除那部分。

于 2010-10-26T19:40:39.297 回答
1

尝试创建一个 udl 文件来创建您的连接字符串。然后你可以测试它以确保它正常工作 - http://www.codeasp.net/blogs/hajan/microsoft-net/857/working-with-udl-universal-data-link-files

于 2010-10-26T19:22:10.667 回答