Skip to main content

Database Connectivity in C#

Database Connectivity in C# (Local Database)



  Hello, in this tutorial I am going to show you how to connect the C# application with the local database. So let's get Started.


Step 1: Create A local database file. I am using Access File.

Step 2: Open your C# project and go to the forms where you need a database connection.

Step 3: Use The Following Code To Connect with the database.

    1- need to include this statement in the code at the top. 


   2-need to write this statement in the class of that form.



here the Source in the above code is the path of my Access file which I am using as a database.
the above code is to create a connection object of a database with a data source.

3-use this statement to open the database connection. you can write this code in button click method of the button.



4- within the same button click method you can write this code to display data from the table which is in that Access file.



here the editTable is the Data Grid View component name which I am using to display table data.
This is the code and output.



Comments

Popular Posts

How to create a error message box using notepad

How to create a message box using notepad Step 1- open notepad Step 2- Write this code on notepad X=Msgbox("Press OK.",1+16,"Demo Error") note- in the above code instead of double quoted text you can write anything you want Step 3- save this file as .vbs Step 4- open the ".vbs" file

#How to create your own Run command(Windows+R) to open desired applications.

#How to create your own Run command(Windows+R) to open desired applications. Many times we use shortcuts to open a particular application, we normally place application icon on desktop but sometimes it gets hard to find particular application or program to avoid such situation we use a simple command to open that application using Run window (Windwos+R). Now Let's see how to make our own command to open the desired application.   Step1:- Right Click on Desktop and select New-->Shortcut step2:- Either Type: netbeans.exe or browse to the .exe file of a program if it cannot find .exe by  typing and then click next step3:- after that write any name which you will like to use as a command for opening that program example-NetBeans step4:- then go to the Run(Windows+R) type \Windows and enter the windows folder will open paste the shortcut file that we have created into this folder that's it now let's check your own command o...