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
Solved

accessing MSAccess 2000 from VB6

Posted on 2001-06-15
7
250 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
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Computer crashes, following error message in event manager 5 234
Access query that references subform 5 47
vb6 connector to SQL Server 2 37
vb6 connector to mongodb 2 117
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

789 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