Teach and old Dog new Tricks (Old dumb dog at that)

Posted on 2004-09-13
Medium Priority
Last Modified: 2010-05-02
I have a program that I wrote in vb5 several years ago. It usess an access 97 db and several instances of the datacontrol with bound controlls like datagrids and others.

I would like to convert it to VB6 or even better VB 2005 express, do away with the datacontrols, upgrade to possibly access 2003.

Easy points for the best referance for accomplishing this.  Very detailed explanation with examples would be great, especially on doing away with the datacontrols.

Question by:Gary Dewrell
  • 4
  • 2
  • 2
  • +1

Expert Comment

ID: 12051748
You will need to use ADO to manually connect to your db if you don't want the data controls.

It's quite simple.....

Next about your code...your VB5 code should work nicely in VB6, as VB6 only offers enhancements to VB5, it still uses all the stuff we did in VB5 and just add's to it.

About the DB...Get Newes access, open your old DB, and convert it to the new access format.

This should get you started....

Maybe you could post some more deatiled questions?
LVL 26

Expert Comment

ID: 12053350
just curious ... what is "VB 2005 express"
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.


Expert Comment

ID: 12053550
Hmmmm....Looks like it's the new VB.NET (Maybe Whidby) "Light Edition"

LVL 12

Author Comment

by:Gary Dewrell
ID: 12060231
That is correct x50! It is a lite version of vb.net.  They also have a sql express, c# express, etc. It is mainly for those who just want to do winforms.

Back to my issue.  Could some one take a moment to explain how to use ADO.

I have several forms accessing several tables from my database.
Im just looking for sorta guide to get started.

Some forms are accessin several tables at the same time. So a quick explanation (not real detailed, I want to figure that out myself, but I need a push) of how to use ado to connect to the database, execute querys that update records, retrieve data for use in datagrids, etc..  

One specific question I have is do I have to write the same code over and over again on each form?

Accepted Solution

x50Fade earned 2000 total points
ID: 12061679
HI Old dog....hehe

K, I can help ya out with ADO, but not ADO.net. VB6 uses ADO and VB.net uses ADO or ADO.NET.

To connect to a DB through ADO, you need mainly two objects.

A Connection Object (Connection to the DB)
A Recordset Object (Used for running queries on tables and retreiving data)

On your last question....The connection you only build once, You can put the data Access Code (Recordset Stuff) in a Module, and use it over and over.

A quick example

Private Sub MDIForm_Load()
    Set dbAse = New Connection
        dbAse.CursorLocation = adUseServer
        dbAse.Open "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\systems.mdb"
End Sub

In the Module, where RS is defined as a Public Variable

Public Function Open_Recordset(FieldstToOpen As String, TableToOpen As String)

   On Error GoTo Open_Recordset_Error

rs.Open "Select " & FieldstToOpen & " from " & TableToOpen, dbAse, adOpenKeyset, adLockOptimistic

   On Error GoTo 0
   Exit Function


    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Open_Recordset of Module General" & vbCrLf & vbCrLf & TableToOpen
End Function

Once the recordset is open, you can iterate through it like this...

While not rs.eof
 msgbox rs.fields("Fieldname")

Actually a lot more to it...but this should get you started...

Expert Comment

ID: 12061683
Oh yes and you have to set the propper references in your project....look for Microsoft ActiveX Data Objects and add it as a reference.


LVL 14

Expert Comment

ID: 12066259
A thorough explanation on why to take the leap (ADO to ADO.NET) and how to go about it:

Migrating Code and Concepts from ADO "Classic" to ADO.NET


Best regards,

LVL 12

Author Comment

by:Gary Dewrell
ID: 12070288
Thanks guys, I will look trough all of these within the next 24-28 hours and award appoints.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

621 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