Connect MS Access Database to C# Console Application (Select-Insert-Update-Delete) – C# Programming Example
C# Console Database General Methods While Loop

Connect MS Access Database to C# Console Application (Select-Insert-Update-Delete)

Here in this article, I will show you how to connect a C# Application with MS Access 2016 database.

Step 1:  Open MS Access, click on a Blank Desktop Database. Give the database name “dbSchool.accdb“. and then click Create.

Step 2: Now create a Table in database, You can name a table anything you want, here I named it “Student” . There are three columns in the table ID, FirstName and LastName like the following,

Step 3: Now open Visual Studio, start a new Console  Application and give any name you want.

Step 4: Now Drag and Drop database file from the Documents to the Project Directory folder.



Step 5: Write a Namespace for connectivity as in the following code snippet.

Step 6: Define global variables.

Step 7: Create a method for get the list of students.

Step 8: Create a method for insert a student.

Step 9: Create a method for updating the data of the student

Step 10: Create a method for delete a record of the student by id column

Step 11: Main method

Finally, finished  the project.


Here are the all codes:





Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: