[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Databases and VB - Help needed

Posted on 2002-04-21
7
Medium Priority
?
147 Views
Last Modified: 2010-05-02
Hi, I have a school assignment to do. It has to involve some sort of a database solution.
I've decided to make an address book (i know its been done and overdone). The problem I'm facing is ADO, or what I found to be the only way of using Access databases.
I have been able to make a database and set out the tables and such, yet I am still unaware of how to put data into it, and then read from it.
I've been reading the whole MSDN which the school has, and still cant find much on it.
Can someone point me in the right direction? Perhaps I should use something else - apart from ADO?

Thanx for everything
0
Comment
Question by:romka
[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 6

Expert Comment

by:xSinbad
ID: 6958848
I prefer DAO and would use such as follows.

'To connect and open a table;

Dim RS as recordset
Dim DB as Database
Dim strData

set DB = opendatabase("c:\database.mdb")
set RS = DB.Openrecordset("TableName", VBopenDynaset)

'To move through the recordset

' First Record
RS.MoveFirst

'Next Record
RS.MoveNext

' Add recod to a variable
strData = RS!FieldName

' Change data in field
RS.Edit
RS!FieldName = "Whatever"
RS.Update


'Then to clean up afterwards
set RS = Nothing
set DB = Nothing



I hope that helps you out a little


Cheers
Marcus





0
 
LVL 3

Expert Comment

by:sridhar_PJ
ID: 6958911
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:alfanhendro
ID: 6958994
using DAO,if you use MsAccess 2000, you may need to convert your database to previous version.
-open your database
-select tools
     ->database utility
     ->convert database
     ->to prior access database version

Regards
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 800 total points
ID: 6959357
Ok, here is a simple ADO tutorial that you can adapt very easily:

*** Form Code ***

Private cnnAccess As ADODB.Connection
Private rstData As ADODB.Recordset

Private Sub Form_Load()
  'Open Connection
  Set cnnAccess = New ADODB.Connection
  cnnAccess.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\myfolder\mydatabase.mdb;"
  cnnAccess.Open
  'Open Recordset
  Set rstData = New ADODB.Recordset
  rstData.Open "Select * From MyTable",cnnAccess,adOpenStatic,adLockOptimistic
End Sub

Private Sub Form_UnLoad()
  'Close and destroy recordset
  If rstData.State <> adStateClosed Then
    rstData.Close
  End If
  Set rstData = Nothing
  'Close and destroy connection
  If cnnAccess.State <> adStateClosed Then
    cnnAccess.Close
  End If
  Set cnnAccess = Nothing
End Sub

You now have the basics to access your data, you can use the recordset's methods and properties to retrieve/update/insert/delete records.

Private Sub DisplayValues()
  With rstData
    txtField1.Text = .Fields("Field1").Value
    txtField2.Text = .Fields("Field2").Value
  End With
End Sub

Private Sub SaveRecord()
  With rstData
    .Fields("Field1").Value = txtField1.Text
    .Fields("Field2").Value = txtField2.Text
    .Update
  End With
End Sub

Private Sub NewRecord()
  rstData.AddNew
End Sub

And so on.
0
 

Author Comment

by:romka
ID: 6970473
Thank you very much for your help.
It so far has helped my project

Thank you
0
 

Author Comment

by:romka
ID: 6970496
Thank you very much.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
Suggested Courses

649 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