简体   繁体   English

连接VB6和MS Access 2007

[英]Connecting VB6 and MS Access 2007

I'm trying to create a simple visual basic 6 program/database that uses ms access 2007 as the back end. 我正在尝试创建一个简单的Visual Basic 6程序/数据库,该程序/数据库使用ms Access 2007作为后端。 I have no background with vb programming. 我没有vb编程的背景。 I just want to as what are the simplest way(s) in connecting vb and access? 我只想作为连接vb和访问的最简单方法是什么? 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. 谢谢。

Use ADO. 使用ADO。 Theres a tutorial in the VB6 user guide about connecting VB6 to Access. VB6用户指南中提供了有关将VB6连接到Access的教​​程。 http://msdn.microsoft.com/en-us/library/aa240855(v=vs.60).aspx http://msdn.microsoft.com/zh-CN/library/aa240855(v=vs.60).aspx

You will need to use an appropriate connection string for Access 2007. http://www.connectionstrings.com/access-2007 您将需要为Access 2007使用适当的连接字符串。http://www.connectionstrings.com/access-2007

These websites might be suitable for you. 这些网站可能适合您。 I found them using Google and searching for "vb 6 access 2007". 我发现他们使用Google并搜索“ vb 6 access 2007”。


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

Don't use Microsoft.Jet.OLEDB.4.0 for provider. 不要将Microsoft.Jet.OLEDB.4.0用于提供程序。 You need to use the "Microsoft.ACE.OLEDB.12.0" 您需要使用“ 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: 来自http://www.codeguru.com/forum/showthread.php?t=472469的建议是:

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. 如果您使用的是Microsoft DAO 3.6对象库,请尝试删除对该对象的引用,而是将其设置为对Microsoft Office 12.0 Access数据库引擎对象库的引用。




The best answer from http://answers.yahoo.com/question/index?qid=20090209051024AAl8ZRC is: 来自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        




The suggested answer from http://www.database-answers.com/microsoft/Access-Modules-DAO/32414159/opening-access-2007-in-vb6-accessdatabaseengineexe-acedaodll.aspx is: 来自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    

I hope these suggestions and the links provided will give you some more insight into the relationship between VB 6 and Access 2007. 我希望这些建议和提供的链接可以使您对VB 6和Access 2007之间的关系有更多的了解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM