Create a Simple Text Database

(Advantage: file size and easy creation)

by Rick Meyer

There is one great drawback to Text Databases. Although you can easily add new records, you can not edit previous records.
To actually create the text database, please read the DAO page on this same subject. This page is solely for connecting to the database using an ADO Data Control.
1. Start a new standard exe.
2. In Project->Components add the ADO Control
3. On Form1 put an ADO Data Control.
4. On Form1 put 3 Textboxes.

      Form1 should look like the picture above.

To connect to a database using an ADO Data Control the connection string must be set in the properties of the control. Click [here] to refer to my transition page to see how to do this.

Provider = Microsoft.Jet

Now for the Data Source the thing to remember is that we are not using an Access type (*.mdb) database. Remember that an Access database contains all its tables in a single file. A text database contains only one table per file. Accordingly the Source is set to the Directory in which the text file exists.

Data Source = C:\Program Files\DevStudio\VB if phoneno.txt is in that directory.

To connect to a text database you must also provide in the connection string Extended Properties=Text; In the ISGData Control put this in the Connection Options.

Extended Properties = Text;

Also require for the ISGData Control is an entry in the SQL statement box. The following statement selects all the records in the table:

Select * From phoneno#txt

Since you have already provided the connection string, a drop down list of the tables in the database should appear when you click on the RecordSource (or Table). Choose phoneno#txt.
Now connect each Textbox to the Data Control.

To do this find the DataSource property of each Textbox. Click on the tab and choose the ADOData1 control from the dropdown list.

Now connect each Textbox with a field in the database.

To do this find the DataField property of each Textbox. Click the tab for each Textbox and choose one of the three fields for each.

That is all there is to it! You don't have to write any code!

Run the program and click on the right arrow tab of the Data1 control after you have entered a name and number.

  • Click the left arrow to view previous records.
  • All information will be automatically saved to the text file!