1
我有一個VB.NET函數,我想連接它用於連接到SQL Server數據庫並返回記錄集。我是VB和SQL的新手,所以我希望這很簡單,但我確信我的連接字符串和SQL查詢是正確的,因爲他們是由隊友檢查的。我有異常信息的副本VBA中的ADODB連接問題
' Retrieve Record Set
Private Function GetRecords() As ADODB.Recordset
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
With conn
.ConnectionString = "Server=12.345.678.9;Database=db01;User Id=userid01;Password=passwordyword"
.Open() ' Exception Thrown Here
rs.Open("SELECT * FROM [Table] ;", "sql")
rs.Close()
.Close()
End With
Return rs
End Function
異常消息的代碼如下:
An exception of type 'System.Runtime.InteropServices.COMException' occurred in ThisProject.dll but was not handled in user code
Additional information: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
任何和所有幫助將不勝感激!謝謝!
在您的連接字符串中,您必須提供您使用哪個驅動程序?例如oledb,oracleoledb等.. –