need example of simple database program

Posted on 1998-09-23
Last Modified: 2010-04-30
i need demo project that is a simple database program
for example it must have these fields - name, age, email
i also need the data shown in a listview control
i should understand it, possibli with descriptions of the things made
the price is good for this
Question by:marusha
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
  • 4
  • 3
  • 2

Accepted Solution

vmano earned 200 total points
ID: 1436277
i can give you the source code for this.
all will be in my comments.

Author Comment

ID: 1436278
ok... i am waiting
i am not newbie to VB, i just wanted to let you know

Expert Comment

ID: 1436279
OK. Here is how you create an access data base from your VB code.
From your Project/References, check the reference for
Microsot DAO 2.5/3.0 Compatibility library.

here is the code for creating the data base and some records.
    Dim DB      As Database
    Dim TD      As TableDef
    Dim FD      As Field
    Dim RS      As Recordset
    Dim i       As Integer
    'Create the database, if you don't have one.
    Set DB = CreateDatabase("C:\test.mdb", dbLangGeneral)
    'Create the table in  that database
    Set TD = DB.CreateTableDef("Table1")
    'Now define the fields Name, Age and EMail as text fields.
    Set FD = TD.CreateField("Name", dbText)
    'this will append the fields in the table
    TD.Fields.Append FD
    Set FD = TD.CreateField("Age", dbText)
    TD.Fields.Append FD
    Set FD = TD.CreateField("EMail", dbText)
    TD.Fields.Append FD
    'Now append the Table to the Database
    DB.TableDefs.Append TD
    'Now that the database has fields,
    'add some records through a recordset
    Set RS = DB.OpenRecordset("Table1", dbOpenTable)
    For i = 1 To 5      'Add five records
        RS.AddNew       'Add a new record
        RS!Name = "Name" & i
        RS!Age = "Age" & i
        RS!email = "EMail" & i
    Next i
    'Close both the recordset and database

if you don't understand anything, post a comment.
wait for my next comment to show the data in a list box control
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.


Expert Comment

ID: 1436280
OK. Here is the code to show it in a listbox.

    Dim DB      As Database
    Dim RS      As Recordset
    Dim rcount  As Integer
    Dim i       As Integer
    Set DB = OpenDatabase("C:\Test.mdb")
    Set RS = DB.OpenRecordset("SELECT * FROM Table1;")
    rcount = RS.RecordCount
    For i = 0 To rcount - 1
        List1.AddItem RS!Name & "-" & RS!age & "-" & RS!email
    Next i

let me know if this helps,

Author Comment

ID: 1436281
this works fine
i need something more and i'll pay you
i can pay you 400 if you really help me further , not kiddin
i want an element in my form (i don't know it's name, it may be this listbox) that aligns the data in the database in columns like Explorer does with the files, sizes, dates and so on
how to make this columns and when clicked a column header it aligns the data by date, by email , by name and so on

i am waiting
if you can't answer PLEASE tell me
don't stop commenting, please, i need you vmano


P.S. i am a 18 year blonde girl for your information

Expert Comment

ID: 1436282
Use a listview control instead of the listbox. It is part of the windows common controls and allows you to sort easily.
To make it look like explorer you need to set the view property to lvwReport.

You can setup the columns at design time or runtime whichever you prefer.

The code to do it at runtime is:

    ListView1.View = lvwReport
    ListView1.ColumnHeaders.Add 1, "Name", "Name", 1000
    ListView1.ColumnHeaders.Add 2, "Age", "Age", 1000
    ListView1.ColumnHeaders.Add 3, "Email", "Email", 2000

To add the data to the listview:

Dim newListItem As ListItem

    For i = 0 To rcount - 1
       Set newListItem = ListView1.ListItems.Add(, RS!Name, RS!Name)
       newListItem.SubItems(1) = RS!Age
       newListItem.SubItems(2) = RS!Email
    Next i
    Set newListItem = Nothing    

To sort the data on columns:

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    With ListView1
        If .Sorted And .SortKey = ColumnHeader.Index - 1 Then
            If .SortOrder = lvwAscending Then
                .SortOrder = lvwDescending
                .SortOrder = lvwAscending
            End If
            .SortOrder = lvwAscending
            .SortKey = ColumnHeader.Index - 1
            .Sorted = True
        End If
    End With
End Sub


Expert Comment

ID: 1436283
According to your actual question you just asked me about a simple DB program and to show the data in a listbox control. i did that. now give me the points. coming to your next question, please post another question and i am sure i will answer it.


Expert Comment

ID: 1436284
I think I've answered the second question, unless marusha has an objection to using a listview control (which is a much nicer control than the standard listbox).

I should have mentioned that the code for sorting the data sorts in ascending order when you first click on the Column Header, and in descending order if you click on it again.

marusha: Have I answered your second question?

Author Comment

ID: 1436285
ok vmano i am paying you
as for the sjrl's answer i want to pay you too
i'll post another question and you'll copy and paste and i'll pay you too (200 points of course)
i'll post the question under 'marusia' nick

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help me. 3 79
Child Form in front 4 66
How to read File Date Created using VB6 8 71
add criteria to query in VB, Access 2003 2 49
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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

752 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