Use of Namespace (namespace)

xiaoxiao2021-03-06  84

Author: Flying

About Namespace (Name Space) is common <% @ import namespace = "system.data"%>, this is the Namespace, which provides us, this is different from ASP, we win sp.net must first reference The corresponding features can be used after we operate the Namespace. In fact, it is white, a namespace; is a component I simply list some common Namespace.

<% @ Import namespace = "system.data"%> Used when processing data

<% @ Import namespace = "system.data.ado"%> Using ADO.NET;

<% @ Import namespace = "system.data.sql"%> SQL Server database dedicated

<% @ Import namespace = "system.data.xml"%> Do not look at XML to use

<% @ Import namespace = "system.io"%> Used when handling files

<% @ Import namespace = "system.web.util"%> When you send an email, you will use it.

<% @ Import namespace = "system.text"%> Text encoding

Operating database needs

Explain Namespace, we can formally discuss the application of the database. As can be seen from above, we operate the database, we need to reference the following two namespace

<% @ Import namespace = "system.data"%>

<% @ Import namespace = "system.data.sql"%>

In fact, System.Data.sql can be replaced with system.data.ado, SQL is SQL Server dedicated, ADO can support any database (as long as there is a corresponding driver on the host, such as Access, MySQL, Oracle, etc.), Here, because the database of the flying knife is SQL Server, you can use ADO, but think about M $ separate SQL separately, why don't you use it? As for how much benefits it can, the flying knife has not been tested, and SQL Server is definitely better than ADO.

Whether it is ADO or SQL, they all have several basic objects for operation.

Connections links to a database so that the following applications (similar to the connections in ADO)

Commands to execute sql statements

DataReader reads the data content returned after execution

DataSet stores data, powerful, we will explain

DataSetCommand executes the SQL statement and stores the data into DataSet

It may be the most difficult to understand this is Dataset, we will not take care of him first, first take soft knife.

Connections (SQLCONECTION or Adoconnection)

Its main task is to establish a link to the database server.

<% @ Page language = "c #"%>

<% @ Import namespace = "system.data"%>

<% @ Import namespace = "system.data.sql"%>