Solved

accessing MSAccess 2000 from VB6

Posted on 2001-06-15
7
252 Views
Last Modified: 2010-05-02
I now need to access  MSAccess 2000 from VB6. Please can you let me know the procedure or point me in the right direction.
0
Comment
Question by:Thomas45
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 18

Expert Comment

by:deighton
ID: 6194813
use ado
0
 
LVL 1

Expert Comment

by:BartonM
ID: 6194826
Hi Thomas,

To access an MSAccess database you can use an ADO connection. First you have to enable ADO by selecting the ActiveX Data Objects type library in Project->References.

If you want to access the data in code only, you can use the following code to make a connection:

dim cn as ADODB.Connection
dim rs as ADODB.Recordset

Set cn = New ADODB.Connection

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source = C:\database.mdb"

set rs = new ADODB.Recordset
rs.Open "SELECT * FROM Table1", cn


Another way is to add the ADO Data Control (adodc) to a form. With this control you can also connect to a database.

BartonM
0
 
LVL 3

Expert Comment

by:sombell
ID: 6194828
or Microsoft DAO

either will do. Just add the reference to the project (Project Menu, then References...)

Sombell
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6194851
You need to learn the usage of how to open a Connection, a recordset, execute a query, retrieve data using recordset, save data using recordset. Learn about ADO, you could start from: http://www.microsoft.com/data/ado/default.htm

ok, to just give some idea on how to do it:

You need to set Project/References in VB to : Microsoft ActiveX Data Objects 2.5 (or later), that you have in your m/c.

To open a connection to Access do like this:

Dim Conn1 As ADODB.Connection
Conn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                   "Data Source=\pathname\Db1.mdb;" & _
                   "User Id=admin;" & _
                   "Password=;"

To open a recordset (a set of records):

Dim rs1 As Recordset

Set rs1=New Recordset
rs1.Open "Select * FROM able1",Conn1,adOpenKeySet,adLockOptimistic

To get data from recordset:

Text1.Text = rs1("field1name").Value

To add data to table:

rs1.AddNew
rs1("field1")=Value1
rs1("field2")=Value2
:
rs1.Update

To edit data, you could locate the record, using FIND method, and then do as above, but without AddNew statement.

To delete data, you could locate the record, and do,
rs1.Delete

Thats it. I am not sure, this is what you wanted.

If not, please, ignore this, and explain, what you wanted.
Thank you.

Cheers.

0
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 6194853
But make sure that if you are using ADO that you have at least version 2.1 or higher version 2.0 does not allow use of MS access 2000 databases. If you are using DAO you also need to make sure that your project references are for DAO 3.6 rather than 3.5 as the older versions are not compatible with access 2000. YOu can download the latest versions of MDAC from http://www.microsoft.com/data I would recommend v2.51 as v2.6 does not include all the jet drivers. These are available seperately from http://www.microsoft.com/data/download_Jet4sp3.htm

If you are using VB6 SP4 then you will already have at least MDAC 2.5 installed and should be able to select the appropriate references without any extra downloads.
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6194862
oops, when I was looking at, no other comments, was there.
0
 

Author Comment

by:Thomas45
ID: 6206438
I need the DAO 3.6, thats it, I am updating from 2.5/3.5 and was not sure what I need to access
msaccess2000 database.

Thanks
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question