Designing a database application using Ado.net

Source: Internet
Author: User

Understanding ADO and Ado.net

ActiveX data Object (ADO) is a model of Microsoft's database access, which makes it easy to manipulate databases based on this model. At the same time ADO by Microsoft so development tools support, so whether it is VB, VC, ASP development can be used. Therefore, the development of ASP database applications, only in the Code Embedded SQL (Structured Query Language) command, users can easily input, update, and delete the background of the database records. When the client's browser fills in the information requested by the form and presses the "Submit" button, it sends an HTTP request to the Web server over the Internet and on the intranet, which executes the active server specified by the form on the Web server The pages program (a document with a suffix named. asp).

Since ado.net is not just a simple upgrade of ADO, it is an important part of the Microsoft. NET strategy, so what is the difference from the previous one? Now let me tell you this.

The main method used to process data in ADO is OLE DB, and now it is in ado.net. But Microsoft has made a special extension to OLE DB to better support the currently widely used two database Oracle and SQL Server, which are OracleClient and SqlClient classes, of course, because of the large number of database products, OLE DB itself has been upgraded to facilitate the upgrading of previous OLE DB programs. The OLE DB class is represented in. Net.

So what's the difference between the three classes of--oledb, OracleClient, and SqlClient in programming? Thankfully, in. NET in the programming of the database, no matter which one of the 3 classes mentioned above, the 3 classes are similar in syntax and usage, and can be described by using Itong.

How to learn Ado.net technology

After learning and using the Ado.net programming, the author summarize the following 3 necessary steps, and the order of these 3 steps is absolutely not interchangeable, if in later programming found in the sequence of 3 steps or missing a step, then your code is certainly wrong:

1. Use the connection method in the corresponding class to connect to the database. If you use the SqlClient class, then use SqlConnection1 to establish a link to the database.

2. Open this link.

3. Execute the command method in the corresponding class to specify the SQL statement to execute. Use SqlCommand to execute the specified SQL statement, such as using the SqlClient class.

The following two examples are in. NET to use Ado.net programming code. Because SQL Server is simpler to use than Oracle, the database here uses Microsoft SQL Server 2000. The reason is that it can be used directly after installation without configuration. Since you are accessing SQL Server, the class used is certainly the SqlClient class. These two examples are:

1. Add, delete and modify data in the database.

2. Use ADO technology to build a database of SQL Server 2000.

Example One

Start the SQL Server2000, then create a database and a table, and in the table must have a primary key, random input some data. Save this table when you are finished.

The table structure used in this article is as follows:

ID column int type Flag column Primary key
D Column Char type

Table name: Using the system default table name table1

Then open vs.net to build a new project and drag the "SqlDataAdapter" control from the toolbox to the bottom of the window, and then the Data Adapter Configuration Wizard window will run automatically and follow the wizard prompts to complete the operation (figure).

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.