Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What database should I use?

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

Technology Partners: 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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 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