linking visual basic and acces databases(tables)

i have developed my programs in vb and i want the to use tables from access how can i do it
crush_Of_HeartsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

saka123Commented:
Hi there ,

That can be done by atleast two ways . Either use a data control (from the standard vb tool bar ) and set connect , Database and recordsource properties for the control so that it can pick data from the required table . Give path of database and name of table in recordsource . Bind the textboxes to the datasource and link then to a particular field of database .

Second approach , Link thru code . Initially use the wizards . From the Add-Ins  add " VB6 Data form wizard " . Then choose Access and give path for the database and then the table name .
A few clicks of next button and a fully functional vb form is generated . Study the form load code to see the code used for linking thru code .

I think this will help . Do keep me posted with the latest .

Raman Saka
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johnmhatCommented:
Crush,
What are you trying to do?  Raman is correct, however, binding the controls to the database at design time can limit the scope of those controls.  I think the second suggestion may work for you better if you want the controls to have some range.  
0
richardlouieCommented:
In VB, click on Project->References on the menubar; select the "Micorsoft DAO 3.6 Object Library"

- Create a MS Access database 'dbase.mdb'.
- Create a table 'tab_ship' with the following fields:
    Field      Data Type
    -----      ---------
    name       text
    state      text
    status     text

- Add a few records, some with status = 'Send'.

- Then add the following code to you VB project:

----------------------------------------

Dim wrkDefault As Workspace
Dim dbsDB      As Database
Dim rsTable    As Recordset
Dim sQuery     As String

    ' Get the Workspace.
    Set wrkDefault = CreateWorkspace("", "admin", "", dbUseJet)
   
    ' Open the database
    Set dbsDB = wrkDefault.OpenDatabase(".\dbase.mdb")

    ' Set the query
    sQuery = "SELECT name, state, status " & _
             "   FROM tab_ship " & _
             "   WHERE status = 'Send'"

    ' Set the recordset.
    Set rsTable = dbsDB.OpenRecordset(sQuery)

    ' Browse through the recordset
    While Not rsArea.EOF
        sName   = rsTable.Fields(0)
        sState  = rsTable.Fields(1)
        sStatus = rsTable.Fields(2)
    Wend

----------------------------------------

The above is pretty flexible.  You can change sQuery to do inserts, updates, and deletes of records in the table.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.