0

これを機能させるためにここですべてを試してみましたが、インターネットランドで見つけることができるdsnのない接続文字列のほぼすべての反復で「キーワードがサポートされていません」というエラーが発生し続けます.2つを以下に示します.

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

正確な答えではありませんが、この Web サイトは常に役に立ちます。

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 に答える