0
好的,先生解释一下我做了什么。从数据集Vb.Net中选择数据
首先,我导入的Access数据库到我的VB程序的时候,然后命名该数据集等
这是我的数据集的外观: 1台 4列
到目前为止,我有这样的:
Dim ds As ElementsDataSet
Dim dt As ElementsDataSet.ElementsDataTable
Dim conn As SqlConnection = New SqlConnection("Data Source=|DataDirectory|\Elements.accdb")
Dim selectString As String = "Select Atomic Mass FROM Elements WHERE No =" & mol
Dim cmd As New SqlCommand(selectString, conn)
If conn.State = ConnectionState.Closed Then conn.Open()
Dim datareader As SqlDataReader = cmd.ExecuteReader()
While datareader.Read = True
MessageBox.Show(datareader.Item("Atomic Mass"))
End While
datareader.Close()
,并在执行这个我得到这个错误:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
感谢你这个固定的,虽然不是使用Jet作为供应商的IM我的问题使用Microsoft.ACE.OLEDB.12.0 – Ciaran