Solved

What database should I use?

Posted on 2000-04-03
9
156 Views
Last Modified: 2011-09-20
I want to create a database to contain strings.  I originally was going to create a multidemensional array, but I decided that the capabilities given to the database types (SQL, record.movenext, etc.) would be very useful.  
I didn't really want to rely on the fact that the cooputer had Access or Excel. How would I create and edit a simple database in my VB application?
0
Comment
Question by:cocor
9 Comments
 
LVL 1

Expert Comment

by:tkuppinen
ID: 2681503
Have you given any thought to putting thee strings into a text file?  Much quicker and less overhead than using a database.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2681537
You should consider using a MDB database (free to distribute - doesn't require Access) with DAO database access method. If you use ADO, you will have to distribute MDAC_TYP.EXE which is about 6.5meg to distribute!
0
 

Author Comment

by:cocor
ID: 2681632
The strings will have a varying amount of descriptors.  Therefore, i would have primary key, name, and then 5-10 more descriptors (each descriptor is a string)each.  A text file would be me searching overhead.

So a DAO database doesn't not require Access, therefore I could use the following code and I will be creating a virtual database while my program is running?


Dim MyVirutalDB As Database
Set MyVirutalDB = OpenDatabase("c:\MyVirutalDB.mdb")

Is this using the Microsoft Jet DB?
0
 

Author Comment

by:cocor
ID: 2681645
The strings will have a varying amount of descriptors.  Therefore, i would have primary key, name, and then 5-10 more descriptors (each descriptor is a string)each.  A text file would be me searching overhead.

So a DAO database doesn't not require Access, therefore I could use the following code and I will be creating a virtual database while my program is running?


Dim MyVirutalDB As Database
Set MyVirutalDB = OpenDatabase("c:\MyVirutalDB.mdb")

Is this using the Microsoft Jet DB?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:Marine
ID: 2681745
No this will not do it. You would need to reference Dao.Then use tableDefs object to Create A Database. Your code would just establish connection to an already exisiting database. i'll post a link in a few.
0
 
LVL 6

Accepted Solution

by:
Marine earned 50 total points
ID: 2681758
Here is some code.
Sub NewDatabase()
    Dim wspDefault As Workspace, dbs As Database
    Dim tdf As TableDef, fld1 As Field, fld2 As Field
    Dim idx As Index, fldIndex As Field

    Set wspDefault = DBEngine.Workspaces(0)
    ' Create new, encrypted database.
    Set dbs = wspDefault.CreateDatabase("Newdb.mdb", _
        dbLangGeneral, dbEncrypt)
    ' Create new table with two fields.
    Set tdf = dbs.CreateTableDef("Contacts")
    Set fld1 = tdf.CreateField("ContactID", dbLong)
    fld1.Attributes = fld1.Attributes + dbAutoIncrField
    Set fld2 = tdf.CreateField("ContactName", dbText, 50)
    ' Append fields.
    tdf.Fields.Append fld1
    tdf.Fields.Append fld2
    ' Create primary key index.
    Set idx = tdf.CreateIndex("PrimaryKey")
    Set fldIndex = idx.CreateField("ContactID", dbLong)
    ' Append index fields.
    idx.Fields.Append fldIndex
    ' Set Primary property.
    idx.Primary = True
    ' Append index.
    tdf.Indexes.Append idx
    ' Append TableDef object.
    dbs.TableDefs.Append tdf
    dbs.TableDefs.Refresh
    Set dbs = Nothing
End Sub

Ofcourse you will be needing additonal code to populate the fields and the search though them. This code just creates a datbase and tables. Also fields, sets primary key. Here isthe link.

http://msdn.microsoft.com/library/devprods/vs6/vbasic/dao360/dt_damthCreateDatabaseX.htm
0
 

Author Comment

by:cocor
ID: 2681879
So this is used by adding the DAO 3.60 Reference Object Library.
What if I only have a selection of 2.5/3.5, 3.0, or 3.51 when I go to Project->References in my workspace.  What is the difference?
0
 

Author Comment

by:cocor
ID: 2681893
Marine, I will be excepting your answer.  I just wanted to know what type of reference object would be best for this solution
0
 
LVL 6

Expert Comment

by:Marine
ID: 2681992
I would suggest referencing 3.6 because its the latest for DAO. Good Luck.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now