Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link VB6 to MS Access Database

Status
Not open for further replies.

JSD1976

Programmer
Aug 17, 2004
16
0
0
US
Hello,

I have been working with MS Acces for about four years now, and have just recently entered the world of VB6. I am trying to link VB6 to one of my Access databases. I first tried to do this by adding a DataEnvironment connection. This works, but I can't change the records or add data into blank fields in each record. I have researched that a Data button should be added. However, when I try to do this, it fails. I choose a database name and enter the link in the DatabaseName property, but when I try to enter a Record Source property, I get an error "Unrecognized Database Format." Is there a specific way to modify the DataEnvironment so I can link to my Access database and change, add new, and update records through VB6? I am also curious why I can't use the Data button, because it is explained so simply in the most Beginner level of tutorials for VB6 I have found. As always, all of your thoughts are appreciated, and keep me from giving up.

Thanks

Jeremy
 
Few ways are available:

decalare (prefer in module)
'in general declaration
public DB as database
public tblMain as recordset
'''''''
' in moduleLoad
dim strFileName as string
strFileName=App.Path & "\dbName.mdb"
' or your actual Path
set DB=opendatabase(strfileName)
set tblMain=DB.openrecordset("table name in db")

Another way is to use the adodc control , then connect it to the database, can be dune in the connectionString property. And then add the DataGrid control, and set its DataSource property to the adodc you've just added.

Theres a lot of reading to do with the ado and dao bindings.
My sugesstion, take the first way
nivini

 
If you are now moving to VB then start using ADO.

and

will have plenty of example of connections strings.

If you search these forums/faq's you will also find many examples of how to use ADO.

If at all possible avoid using the adodc control and do all you can with plain code.


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
And, from the sounds of your error message, you are not using the most recent service pack for VB6. You should download and install Service Pack 6 and also download the latest version of MDAC 2.8.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top