---
title: "How to Create Table in MS-Access Database Using C# Code?"  
description: "Microsoft Access database is a database management system from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical u"  
author: "Anonymous User"  
published: 2012-04-10  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/293/how-to-create-table-in-ms-access-database-using-c-sharp-code  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How to Create Table in MS-Access Database Using C# Code?

Microsoft [Access database](https://www.mindstick.com/forum/385/access-database-datatype-problem) is a [database management](https://www.mindstick.com/forum/34816/what-is-mapping-constraints-in-database-management-system) system from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical [user interface](https://www.mindstick.com/interview/22909/user-interface-objects-in-cocoa) and software-[development tools](https://answers.mindstick.com/qa/93973/name-some-content-development-tools-you-re-familiar-with). In this blog I will explain you how to create a [table in MS](https://answers.mindstick.com/qa/96625/differentiate-between-a-form-and-table-in-ms-access)-Access database. Let’s take a look on it.

To create a table in MS-Access database, **first of all you’ve an existence database** file or you have to create a new [database file](https://www.mindstick.com/forum/159377/how-to-add-edit-retrieve-data-using-local-database-file-in-microsoft-visual-studio-2012). After creating the database file; just write the following line of code to create the table in MS-Access database.

##### Code for MS-Access 2003:

```
// Creating OLEDB connection string for Ms-Access 2003 database file            OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source= D:\\Arun Singh\\MsAccessFile\\MyDatabase1.mdb; OLE DB Services=-1");            // Open the connection            myConnection.Open();            // Create Oledb command to execute particular query             OleDbCommand myCommand = new OleDbCommand();            myCommand.Connection = myConnection;            // Query to create table with specified data columne            myCommand.CommandText = "CREATE TABLE tblIdentityTesting([MyIdentityColumn] long, [Name] text)";            myCommand.ExecuteNonQuery();            MessageBox.Show("Table Created Successfully");
```

**\****Code for MS-Access 2007:**

## \

```
// Creating OLEDB connection string for Ms-Access 2007 database file            OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= D:\\Arun Singh\\MsAccessFile\\MyDatabase.accdb;Persist Security Info=False;");            // Open the connection            myConnection.Open();            // Create Oledb command to execute particular query             OleDbCommand myCommand = new OleDbCommand();            myCommand.Connection = myConnection;            // Query to create table with specified data columne            myCommand.CommandText = "CREATE TABLE tblIdentityTesting([MyIdentityColumn] long, [Name] text)";            myCommand.ExecuteNonQuery();            MessageBox.Show("Table Created Successfully");
```

\
This is a brief description about on creating a table in MS-Access [database using C#](https://www.mindstick.com/forum/404/how-to-create-a-table-in-ms-access-database-using-c-sharp-code) code. I hope this blog will help you in understanding that how to create a table in MS-Access database using [C# code](https://www.mindstick.com/articles/334681/5-tips-to-writing-clean-c-sharp-code).

---

Original Source: https://www.mindstick.com/blog/293/how-to-create-table-in-ms-access-database-using-c-sharp-code

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
