我一直在嘗試修復已經使用100%連接到Oracle的項目。他們正在嘗試升級項目以開始使用SQL Server 2012 Management Studio。但是我有問題連接到數據庫。我們使用Windows身份驗證。使用VB.NET 2010連接到SQL Server 2012時出錯
我可以使用Management Studio和Windows身份驗證直接登錄到SQL Server 2012。如果我創建一個全新的WindowsApplication1
項目來測試連接代碼,它工作正常,我使用這個代碼(並得到一個錯誤是在conn.Open()
):
Imports System.Data.SqlClient
Public Class Open_Filing_Image
'Create ADO.NET objects.
Private myConn As SqlConnection
Private myCmd As SqlCommand
Private myReader As SqlDataReader
Private results As String
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'Create a Connection object.
Dim connStr As [String] = "Server=servername; Database=dbname; Integrated Security=True"
myConn = New SqlConnection(connStr)
'Create a Command object.
myCmd = myConn.CreateCommand
myCmd.CommandText = "SELECT DdocName FROM dbo.Document WHERE XAlaskaID = '72010' and DdocType = 'Filings'"
'Open the connection.
Try
myConn.Open()
MsgBox("Connection Open ! ")
Catch ex As Exception
MsgBox("Can not open connection ! ")
End Try
myReader = myCmd.ExecuteReader()
'Concatenate the query result into a string.
Do While myReader.Read()
results = myReader.GetValue(0)
Loop
'Display results.
Dim documentID As String = results
Dim outPath As String = "http://address.internet`enter code here`/" + documentID + (".pdf")
System.Diagnostics.Process.Start(outPath)
'Close the reader and the database connection.
myReader.Close()
myConn.Close()
End Sub
End Class
錯誤消息:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The specified data could not be decrypted.
謝謝。
您的問題陳述是矛盾的。你說過「如果我創建一個全新的WindowsApplication1項目來測試連接代碼,它工作正常」,但是會描述一條錯誤消息。 – Dai
同樣的問題在其他地方也有報道,有幾種可能的原因和解決方案,您確定這些都不適用嗎? http://stackoverflow.com/questions/34430550/a-connection-was-successfully-established-with-the-server-but-then-an-error-occ – Dai
是的,我測試我的conde與任何VS 2010,2013和2015年和連接,我可以拉sqlcommand和sqlreader罰款。但我正在開發一個已經由vb.net 2010編寫的舊程序員構建的項目,並且所有連接都基於oracle。即時通訊只是試圖建立一個簡單的連接來測試,但這是我得到的消息。 –