嘗試看似所有的東西在這裏得到這個工作,但我不斷收到「關鍵字不支持」的錯誤幾乎每一個dsn-less連接字符串的迭代我可以找到在那裏互聯網土地,兩個如下所示。DSN無連接到VB.NET中的SQL服務器
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-less連接正確的連接字符串中的任何想法?
謝謝!
真棒,這工作,但現在我所有的數據源被炸出來,如果我嘗試在那裏沒有DSN連接字符串。在我的項目>設置>(連接字符串)中定義的一個...任何想法爲什麼? – Tom 2010-10-26 19:51:08
你有什麼樣的樣品嗎?我正在安裝消耗我電腦靈魂的東西,所以我現在無法打開VB。如果可以,請告訴我你現在有什麼(明顯改變敏感的東西)。你用什麼版本的VS? – 2010-10-26 19:53:59
VS 2010.基本上我有數據集綁定到連接字符串,我需要將連接字符串更改爲無DSN。我想到了這一點後,現在我只需要弄清楚如何更改數據集的連接字符串,以便我可以在開發和生產環境中工作。似乎你可以更改表格適配器的連接字符串,這比更改我無法弄清的應用程序作用域連接字符串更加費用。這有什麼意義嗎? =) – Tom 2010-10-26 20:12:34