连接 VB6 和 MS Access 2007

发布于 2024-12-29 10:45:51 字数 141 浏览 1 评论 0原文

我正在尝试创建一个简单的 Visual Basic 6 程序/数据库,它使用 MS Access 2007 作为后端。我没有VB编程背景。我只是想连接vb和access最简单的方法是什么?我几乎在互联网上搜索了如何执行此操作,但我认为我做错了。有人可以帮助我吗?谢谢。

I'm trying to create a simple visual basic 6 program/database that uses ms access 2007 as the back end. I have no background with vb programming. I just want to as what are the simplest way(s) in connecting vb and access? I've searched almost all over the internet on how to do this but I think I'm doing it wrong. Can anybody help me? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

银河中√捞星星 2025-01-05 10:45:51

使用 ADO。 VB6 用户指南中有一个关于将 VB6 连接到 Access 的教程。 http://msdn.microsoft.com/en- us/library/aa240855(v=vs.60).aspx

您将需要为 Access 2007 使用适当的连接字符串。http://www.connectionstrings.com/access-2007

Use ADO. Theres a tutorial in the VB6 user guide about connecting VB6 to Access. http://msdn.microsoft.com/en-us/library/aa240855(v=vs.60).aspx

You will need to use an appropriate connection string for Access 2007. http://www.connectionstrings.com/access-2007

猫烠⑼条掵仅有一顆心 2025-01-05 10:45:51

这些网站可能适合您。我通过 Google 搜索“vb 6 access 2007”找到了他们。

来自 http://www.daniweb 的建议。 com/software-development/visual-basic-4-5-6/threads/110825 是:

不要使用 Microsoft.Jet.OLEDB.4.0 作为提供程序。您需要使用
“Microsoft.ACE.OLEDB.12.0”

最简单的方法是设置数据链接或数据提供程序。

来自http://www.codeguru.com/forum/showthread的建议.php?t=472469 是:

如果您使用的是 Microsoft DAO 3.6 对象库,请尝试删除对其的引用,而设置对 Microsoft Office 12.0 Access 数据库引擎对象库的引用。

来自http://answers.yahoo.com/question/index的最佳答案? qid=20090209051024AAl8ZRC 是:

Const DBNAME = "c:\customer.mdb"    

Set objFSOA = CreateObject("Scripting.FileSystemObject…    
If not objFSOA.FileExists(DBNAME) Then        
    CreateDatabase    
End if    

Set objConnectionA = CreateObject("ADODB.Connection")    
objConnectionA.Open "Provider= Microsoft.Jet.OLEDB.4.0; " & "Data Source= " & DBNAME    
Dim strSQL     
strSQL = "INSERT INTO Test(col_1, col_2) VALUES (23, 'Test');"     

objConnectionA.Execute(strSQL)     

objConnectionA.Close    

Private Sub CreateDatabase()    
    Dim objADOXDatabase    
    Set objADOXDatabase = CreateObject("ADOX.Catalog")    
    objADOXDatabase.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBNAME    
    Set objConnectionA = CreateObject("ADODB.Connection")    
    objConnectionA.Open "Provider= Microsoft.Jet.OLEDB.4.0; " & "Data Source= " & DBNAME    
    objConnectionA.Execute "Create Table Test(col_1 number, col_2 text(10))"    
    objConnectionA.Close    

 End Sub        

来自http://www.database-answers.com/microsoft/Access-Modules-DAO/32414159/opening-access-2007-in-vb6-accessdatabaseengineexe-acedaodll.aspx 是:

3) In VB6 Project|References,    
    a) Deselect Microsoft DAO 3.6 object library    
    b) Select Microsoft Office 12 access database engine object library    
    c) Select Microsoft Office 12 object library    
    4) no special code changes needed when setting db objects    

我希望这些建议和提供的链接能让您更深入地了解 VB 6 和 Access 2007 之间的关系。

These websites might be suitable for you. I found them using Google and searching for "vb 6 access 2007".

A suggestion from http://www.daniweb.com/software-development/visual-basic-4-5-6/threads/110825 is:

Don't use Microsoft.Jet.OLEDB.4.0 for provider. You need to use the
"Microsoft.ACE.OLEDB.12.0"

The easiest way is to setup a Data Link or a Data Provider.

A suggestion from http://www.codeguru.com/forum/showthread.php?t=472469 is:

If you were using the Microsoft DAO 3.6 Object Library, try removing the reference to it and instead, set a reference to Microsoft Office 12.0 Access database engine Object Library.

The best answer from http://answers.yahoo.com/question/index?qid=20090209051024AAl8ZRC is:

Const DBNAME = "c:\customer.mdb"    

Set objFSOA = CreateObject("Scripting.FileSystemObject…    
If not objFSOA.FileExists(DBNAME) Then        
    CreateDatabase    
End if    

Set objConnectionA = CreateObject("ADODB.Connection")    
objConnectionA.Open "Provider= Microsoft.Jet.OLEDB.4.0; " & "Data Source= " & DBNAME    
Dim strSQL     
strSQL = "INSERT INTO Test(col_1, col_2) VALUES (23, 'Test');"     

objConnectionA.Execute(strSQL)     

objConnectionA.Close    

Private Sub CreateDatabase()    
    Dim objADOXDatabase    
    Set objADOXDatabase = CreateObject("ADOX.Catalog")    
    objADOXDatabase.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBNAME    
    Set objConnectionA = CreateObject("ADODB.Connection")    
    objConnectionA.Open "Provider= Microsoft.Jet.OLEDB.4.0; " & "Data Source= " & DBNAME    
    objConnectionA.Execute "Create Table Test(col_1 number, col_2 text(10))"    
    objConnectionA.Close    

 End Sub        

The suggested answer from http://www.database-answers.com/microsoft/Access-Modules-DAO/32414159/opening-access-2007-in-vb6-accessdatabaseengineexe-acedaodll.aspx is:

3) In VB6 Project|References,    
    a) Deselect Microsoft DAO 3.6 object library    
    b) Select Microsoft Office 12 access database engine object library    
    c) Select Microsoft Office 12 object library    
    4) no special code changes needed when setting db objects    

I hope these suggestions and the links provided will give you some more insight into the relationship between VB 6 and Access 2007.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文