Based on. NET platform of Windows programming Combat (iv) Database operation class Writing

Source: Internet
Author: User

This article supporting source code

We all know that the normal operation of the system without the database operation of this piece, and it has a decisive role in this system, it can be said that without its operating system will not be able to run, so in this section of the course, specifically for the operation of the database to speak out, so that everyone easier to understand the course behind.

OK, get to the point ...

First, let's create a new class with the following methods:

Open the last lesson of our new Questionnairesystem project, right-click the project name, select "Add" to "Class" in the dialog box that appears, select "Class" in the "Add New Item" pop-up, and enter "Dboperate" in the name below, and click "Add", As shown in Figure 4-1 below:

OK, so our dboperate class files are created, but the inside is still blank, so we will work together to write the appropriate method.

Now the first thing we need to do to manipulate the database is to write a way to open the database. Because we are using the ACCESS2003 database, we have to first use a System.Data.OleDb class library and a System.Data class library, method: The top of the new Dboperate file, that is, write a few using ... Place, write the following:

using System.Data;

using System.Data.OleDb;

Second, we need to define the following two database operations objects:

protected OleDbConnection dbconn;//定义数据库连接对象

protected OleDbCommand dbcomm = new OleDbCommand();//定义数据库操作对象

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.