C# And Ms Access Database Tutorial #2 – How To Create Ms Access Database Table In C#
Microsoft Access Database can have multiple tables. So this tutorial shows how to create a new access table. This is all about adding a new table to already existing database.
Table Is a Structure Composed of rows and column. Each column belongs to a particular datatype. So each column should hold a specific type of data like (Images, Text). But not both. You cannot insert an image in text column. Whenever you add a new entry, its added to a new table row. Mostly the first column in table contains ID, Which is unique. The ID is mostly considered as the primary key of the table. Id Must be unique. Primary key cannot hold duplicate values. Values of this nature are auto incremented whenever you add a new row to the table. If you want to retrieve specific row data from the table you can use ID (primary key) since its unique in all rows.
Create A Table And Add Fields
Open The Database From Storage Location.
To create a new table in existing Microsoft access database;
Go to create tab.
Double Click on table.
A new table will be created with auto generated name.
Right click on table name from the left pane and choose design view. (Or select a table and go to view and choose design view from Dropdown menu).
You’ll be prompted to enter table name. Enter the desired name and click OK.
Now you will see two columns the first one is Field name and the second one is Datatype.
The Field Name column stores the the names of the table columns and the second one defines the column types or the type of data that will be stored in different columns. After you create each field name its advisable to give it a Data Type.
i.e. Text, Integer, etc.
The First Field name (ID) is auto generated. This is the tables primary key.
So i am going to add other columns of type text.
And one of type OLE Object. This one will store image files as bytes.