【发布时间】:2015-04-18 05:41:07
【问题描述】:
我正在为学校处理的应用程序遇到一些困难。我正在尝试调用我在访问中创建的数据库,以将 id 代码加载到 Visual Basic 中的组合框。我正在使用 64 位版本的 windows 8.1 和 office 2013。和 Visual Studio Ultimate 2012。我已经安装了 2010 访问数据库引擎。我将首先向您展示我的代码。
Imports System.Data
Imports System.Data.OleDb
Public Class VDObjects
Public Shared strConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Arcanum\Documents\VincentMcMullen\VandelayDB.accdb;Persist Secruity Info=False;"
Public Class Department
'Department ID
Private DeptIDValue As String
Public Property DeptID() As String
Get
Return DeptIDValue
End Get
Set(ByVal value As String)
DeptIDValue = value
End Set
End Property
'Department Description
Private DeptDescrValue As String
Public Property DeptDescr() As String
Get
Return DeptDescrValue
End Get
Set(ByVal value As String)
DeptDescrValue = value
End Set
End Property
'populate a drop down box with all available users
Public Shared Sub PopulateDropdown(ByRef cbSelect As ComboBox)
Dim con As New OleDb.OleDbConnection
con.ConnectionString = strConn
'SQL Query to get department IDs
Dim qry As String = "SELECT DepartmentID FROM tblDepartments "
Dim cmd As New OleDb.OleDbCommand(qry, con)
Try
'first clear the current entries
cbSelect.Items.Clear()
'run and add query and add the values
con.Open()
Dim reader As OleDbDataReader = cmd.ExecuteReader()
While reader.Read()
cbSelect.Items.Add(reader.GetString(0))
End While
Catch ex As Exception
MsgBox(ex.ToString)
Finally
con.Close()
End Try
End Sub
End Class
End Class
它将在读取“con.Open()”的行上失败并立即进入捕获状态。我会告诉我“找不到可安装的 ISAM”。我已经重新安装了 Office,并根据 Microsoft 支持建议验证了它们都是 64 位版本。任何见解将不胜感激。
谢谢
文斯
【问题讨论】:
标签: vb.net ms-access visual-studio-2012