我正在支持一箇舊的vb.net程序,它的數據庫連接到的數據庫已從SQL Server 2005遷移到SQL Server 2008.在SQL Server 2008中是否有一個允許ODBC連接訪問數據庫但不允許VB的設置。 NET以編程方式連接到它?爲什麼我可以通過odbc而不是通過vb.net代碼連接到sql server 2008?
我不斷收到在應用程序中的錯誤是:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
不過,我可以連接到它,當我創建一個系統DSN SQL Server實例,並通過VS2005的工具>>連接到數據庫。
這裏是我使用的連接代碼:
dim strC as string
strC = "data source=bob; database=subscribers; user id=bobuser; password=passme"
dim connection as New SqlClient.SqlConnection(strC)
try
connection.open()
catch ex as Exception
msgbox(ex.message)
end try
connection.Close()
將開發在VS2005 Windows應用程序連接到SQL Server 2008數據庫與使用VS2010有什麼不同? – phill 2011-01-07 06:00:31