如何将Visual Studio 2010与Microsoft Access 2007连接 [英] How do I connect visual studio 2010 with Microsoft access 2007

查看:182
本文介绍了如何将Visual Studio 2010与Microsoft Access 2007连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好开发人员我正在使用visual studio 2010 ultimate和microsoft access 2007开发一个简单的独立数据库,而我试图运行登录表单的测试代码,而visual studio无法连接ms访问,它响应microsoft.jet.oledb.12.0提供程序未在本地计算机中注册。当我将provider = microsoft.jet.oledb.12.0更改为provider = microsoft.ace.oledb.12.0时,它会响应找不到可安装的ISAM



我尝试了什么:



 进口 System.Data 
Imports System.Data.OleDb
Public FrmLogIn
Dim i As < span class =code-keyword> Boolean
Dim ds As < span class =code-keyword> New DataSet
Dim sql As 字符串
Dim da 作为 OleDbDataAdapter
Dim con 作为 OleDbConnection( 提供商= microsoft.jet.oledb.12.0; datasource = C:\ Users \Admin \Desktop\test.accdb
私有 Sub FrmLogIn_Load( ByVal sender As System。 Object ByVal e As System.EventArgs)句柄 MyBase .Load
尝试
con .Open()
Catch OleDbExceptionErr As OleDbException
MessageBox.Show(OleDbExceptionErr。消息, 访问错误
Catch InvalidOperationExceptionErr As InvalidOperationException
MessageBox.Show(InvalidOperationExceptionErr.Message, 访问错误
结束 尝试
如果 con.State<> ; ConnectionState.Open 然后
MessageBox.Show( 数据库连接失败
退出 Sub
< span class =code-keyword>结束 如果

结束 Sub
结束

解决方案

这里有两种可能:JET V12根本没有安装在那台机器上,或者它是错误的类型。检查你的应用:是设置为x86?因为如果不是,你根本不能使用JET数据库引擎,因为它只能在32位版本中使用。

许多年前,JET被ACE数据库引擎取代,并且可用32位和64位版本。

我强烈建议您安装64位版本的ACE数据库引擎并改为使用它:从Microsoft官方下载中心下载Microsoft Access数据库引擎2010可再发行组件 [ ^ ]


您的连接字符串不正确。 Jet的版本是4.0,你可能会考虑从下载Microsoft Access数据库引擎2016 Redistributable官方Microsoft下载中心 [ ^ ]。


您使用的连接字符串不正确; JET的最后一个版本是4.0,它被ACE 12.0取代。



试试这个:

  Dim  con  As   OleDbConnection(  provider = Microsoft.ACE.OLEDB.12.0; datasource = C:\ Users \Admin \Desktop\test.accdb


hello developers i am using visual studio 2010 ultimate and microsoft access 2007 for developing a simple standalone database while i tried to run a test code for login form and the visual studio failed to connect with ms access and it responds "microsoft.jet.oledb.12.0" provider is no registered in the local machine. when i changed "provider=microsoft.jet.oledb.12.0" to "provider=microsoft.ace.oledb.12.0" it responds " could not find installable ISAM"

What I have tried:

Imports System.Data
Imports System.Data.OleDb
Public Class FrmLogIn
    Dim i As Boolean
    Dim ds As New DataSet
    Dim sql As String
    Dim da As OleDbDataAdapter
    Dim con As New OleDbConnection("provider=microsoft.jet.oledb.12.0; datasource= C:\Users\Admin\Desktop\test.accdb")
    Private Sub FrmLogIn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            con.Open()
        Catch OleDbExceptionErr As OleDbException
            MessageBox.Show(OleDbExceptionErr.Message, "Access Error")
        Catch InvalidOperationExceptionErr As InvalidOperationException
            MessageBox.Show(InvalidOperationExceptionErr.Message, "Access Error")
        End Try
        If con.State <> ConnectionState.Open Then
            MessageBox.Show("Database Connection is Failed")
            Exit Sub
        End If

    End Sub
End Class

解决方案

There are two possibilities here: JET V12 isn't installed at all on that machine, or it is but the wrong "type". Check your app: is is set for "x86"? Because if it isn't, you can't use the JET database engine at all as it's only available in 32 bit versions.
JET was superseded by the ACE database engine many years ago, and is available in 32 bit and 64 bit versions.
I'd strongly suggest that you install the 64bit version of the ACE database engine and use that instead: Download Microsoft Access Database Engine 2010 Redistributable from Official Microsoft Download Center[^]


Your connection string is incorrect. The version of Jet is 4.0, you are probably thinking of Download Microsoft Access Database Engine 2016 Redistributable from Official Microsoft Download Center[^].


You are using the incorrect connection string; the last version of JET was 4.0, and it was replaced with ACE 12.0.

Try this instead:

Dim con As New OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; datasource= C:\Users\Admin\Desktop\test.accdb")


这篇关于如何将Visual Studio 2010与Microsoft Access 2007连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆