Senin, 09 Februari 2009

A Simple Database
Here is a list of subjects that will be covered on the programming of Databases

What is a "DATABASE"?

A Database is a collection of records, that can be sorted, removed, searched etc.

A Database allows you to store multiple pieces of information in one file, instead of using several files for each piece of data. Normally a Database contains many fields of data. You can think of a field as a place in which you can hold information, it’s a lot like a variable but you load information from a file and only that variable can get that piece of information.

For example you are keeping information about your record collection, so you have a field called "ARTIST", a field called "RECORD" and a field called "TYPE", now when you put the information into the three fields they are stored in that order in the file. The information is also retrieved in that order when you wish to obtain the data. Storing the data in fields means that you can easily search data if you now what field to search. For example if you want just search by "ARTIST". Then instead of searching the whole file for a string that matches, you can search each "ARTIST" field and miss the other two fields by skipping there position in the file and going to straight to the next "ARTIST" field.

The advantages of Databases are that they are easy to search for specific items, you can add data really easily.

How A Database Works.



The way in which we will get our Database to work is very simple, first we will create template of the fields we are going to be using (ARTIST, RECORD, STYLE). This is done in Visual Basic by placing variables in a TYPE declaration.

This is done so that we can easily access all the variables for are Database fields and so that when we write to the file instead of doing:

ARTIST = trim (txtARTIST.text)

RECORD = trim (txtRECORD.text)

STYLE = trim (txtSTYLE.text)

Put #1, x, ARTIST

Put #1, x, RECORD

Put #1, x, STYLE

We can do:

Typename.ARTIST = trim (txtARTIST.text)

Typename.RECORD = trim (txtRECORD.text)

Typename.STYLE = trim (txtSTYLE.text)

Put #1, x, Typename

This way may seem longer but it’s faster because the is a lot less file access because we are only writing to the drive once when enter new data in stead of several times. As you can see if you have a lot more fields the second method becomes even better, also it is a lot easier to read and harder to get messed up with your variables because you explicitly know that any Typename variables are for read from textboxes and searching etc.


source: http://www.vbexplorer.com/VBExplorer/VBExplorer.asp



-----------------------------------------------

Related:


sqlserver2005-security
view information vb2005
write file in vb2005
Barcode-string-encoderVbnet
Changing-backgroundcolor
Trik finding google
Directly-filling control
Date-time format vb2008
Finding google rank
Domain checker phps cript
Foreign key sql2005
Create-insert-tableadapter
Check datagrid
Hapus error handling vb2008
Function2 vb2008

Tidak ada komentar:

Posting Komentar