PDA

Click to See Complete Forum and Search --> : Creating a datbase


Blasshole
Jun 14th, 1999, 01:10 AM
My dad has asked me to create a simple database program.(I mean simple.) He told me the names of all the fields(columns), but I have no idea how to make a database with vb. I tried using lots 'o textboxes, but as you would guess, that didnt work. Whats the easiest way to make a simple database in vb? The only other task that this program has to do is save the data entered by the user. ANY INFORMATION WOULD GREATLY BE APPRECIATED.

THANKS, Bl*******

thorne
Jun 14th, 1999, 01:54 AM
I would suggest you use Access or someother database program to create the database and then use vb browse the database.

If you don't want to do that, then you can create a TypeDef such as

Type MyData
Product%
Description$
Qty%
End Type

dim Product() as MyData

Then you can enter the text from the text boxes into the member of MyData. The only problem with this is if your database gets very large, because you have to constantly redim the array.

mcleran
Jun 14th, 1999, 05:36 PM
If you have Visual Studio/VB6.0 you have a program called Visual Data Manager. You can use this program to create Microsoft Databases (.mdb). These databases can then be used by Access and/or VB. The help menu should be able to guide you through creating a simple database.

SmithVoice
Jun 15th, 1999, 03:41 PM
A great way to learn how to create databases via code is to get a look at example code, it helps even more if you can get sample code that exactly shows *your* database beig created.

If you're doing Jet databases, using Access as a scratch-pad is very powerful (the VB VisData AddIn is ok in a pinch)..

After you use one of these to create a database file (or if you have any Jet databases on your machine) you can use the free utility at
http://www.smithvoice.com/jet.htm

to reverse-engineer the database to the VB DAO code it will take to create that databse on -the-fly.

It's a very good learning tool and takes care of ALL field and index details

-Robert Smith
Kirkland WA

------------------
http://www.smithvoice.com/vbfun.htm

testermans
Jun 15th, 1999, 09:01 PM
Creating the database is actually the easiest part. From the project window, go to Add Ins, Visual Data Manager, Create MS Access Database. From here, it is pretty self explanatory as far as building your table (add each field & define types & indexes). You can use you VB Project to attach to the database table. Add a data control to your form and Set the Database Name Property to the path where your database is stored and the Recordsource property to the table you want to retrieve the data from. Also each text box that you have on your form, you need to the the Datasource(table name) and Data Field (field in table) properties. This will link your form to the database.

Blasshole
Jun 16th, 1999, 12:52 AM
Wow thanks soo much guys for all that info! Im gonna try all of your suggestions and see which works. Thnanks again, Bl*******.

ScottF
Jun 16th, 1999, 04:46 AM
You can create a database by using this code

Dim db As Database
Dim p As String
' You need to set up a Dialog control by 'going to the menu bar and click project 'then component. Then scroll down until you 'find Microsoft Common Dialog Control 5.o 'and check it and apply
' Next follow same step except for component 'select References then scroll and check 'Microsoft DOA Object Libary and apply
dim db as database
dlgCMD1.DialogTitle = "Microsoft Access"
dlgCMD1.FilterIndex = 1
dlgCMD1.Filter = "Microsoft Access MDBs (*.mdb)|*.mdb"
dlgCMD1.filename = vbNullString
dlgCMD1.CancelError = False
dlgCMD1.ShowSave
If Len(snewname) = 0 Then Exit Sub
snewname = dlgCMD1.filename
end if
Set db = CreateDatabase(snewname, dbLangGeneral, dbVersion30)
db.Execute "Create Table NameTable " & " (ID TEXT,FirstName text, MiddleName text, Lastname text, SocialSecNo number);"
I hope this helps to open it you use statement like
This in your form load sub and datName is A datacontrol. You can use a DBGrid to show your Table
dim dbs as database
Set dbs = OpenDatabase(database Path)
dtaName.DatabaseName = "Database path"
dtaName.RecordSource = "Table Name"
dtaName.Refresh