C # Connect to an Access database
Microsoft Office Access is a relational database management system that is released by Microsoft . It combines the two features of the Microsoftjet Database Engine and the graphical user interface and is one of the system programs for Microsoft Office.
For many small software, using an Access database is a good choice, and here's a quick introduction to using C # to connect to a database.
The first step: We build a project in vs2015 named Accesstest.
650) this.width=650; "src=" http://s2.sinaimg.cn/mw690/005B0qZNgy71rFb506521 "title=" "style=" border:0px; Vertical-align:middle; "/>
Project Establishment
Step Two: create a new Access database file named Test, where the location can be placed on the desktop
650) this.width=650; "src=" Http://s3.sinaimg.cn/mw690/005B0qZNgy71rFlD09Ya2 "title=" "style=" border:0px; vertical-align:middle; "/> database file
Step Three: Add a button to the WinForm form.
650) this.width=650; "src=" Http://s11.sinaimg.cn/mw690/005B0qZNgy71rFsUAOeda "title=" "style=" border:0px; Vertical-align:middle; "/>
Fourth Step: Add Reference System.Data.OleDb;
650) this.width=650; "src=" http://s1.sinaimg.cn/mw690/005B0qZNgy71rFCNEyI00 "title=" "style=" border:0px; Vertical-align:middle; "/>
Fifth Step: Double-click button to add code
650) this.width=650; "src=" http://s13.sinaimg.cn/mw690/005B0qZNgy71rGmvmsk9c "title=" "style=" border:0px; Vertical-align:middle; "/>
Path
650) this.width=650; "src=" http://s3.sinaimg.cn/mw690/005B0qZNgy71rGo1f7I92 "title=" "style=" border:0px; vertical-align:middle; "/> button code and comments
Last-step debug Run
650) this.width=650; "src=" http://s6.sinaimg.cn/mw690/005B0qZNgy71rGuUoex05 "title=" "style=" border:0px; Vertical-align:middle; "/>
Open Database
650) this.width=650; "src=" Http://s6.sinaimg.cn/mw690/005B0qZNgy71rGxe2BTd5 "title=" "style=" border:0px; Vertical-align:middle; "/>
Close the database
Connection successful, congratulations, the database test connection is successful, then you can use the relevant statements to manipulate the database
This tutorial is prepared for the small white, do not like not to spray the following will introduce the database of some operational statements and practical use. Welcome to continue reading, the following is attached to the source address.
The database has to be built itself, and the path has to be modified.
Operating Environment VS2015
Free Source Address: http://down.51cto.com/data/2215791
This article is from the "World is the same" blog, please be sure to keep this source http://970076933.blog.51cto.com/9767314/1887862
C # Connect to an Access database