?
Solved

What database should I use?

Posted on 2000-04-03
9
Medium Priority
?
172 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 70

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

864 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