A ADO (Access data Object)
. NET operations database a set of classes
- DataSet Data Set
- . NET Data provider (Provider) Core object:
Connection
Command
DataReader
DataAdapter
Two. Connection Connection object
1. Create:
SqlConnection conn = new SqlConnection ();
conn.connectionstring= ' link string '
Or:
SQLConnection Conn =new SQLConnection (link string);
2. Open the connection:
Conn.Open (); Open the database;
3. Link string:
(1) Address, database, account number, password
(2) Data Source = Server address, Initial catalog= database name, User id= account, password= password. or "server= server address; database= database name; uid= account; pwd= password. "(abbreviated)
Three Command execution Object
1. Syntax
SqlCommand comm=new SqlCommand ();
comm.commandtext= "SQL statement"//what SQL to execute;
Comm.command=conn//Where to execute
Shorthand:
SqlCommand comm=new SqlCommand (sql,conn);
2. Implementation
2.1 ExecuteScalar ()
2.2 ExecuteReader ()
2.3 Executenomquery ()
3.comm.executescalar ()
3.1 Command starts executing the target SQL statement and gets the results returned by the database
3.2 Get first row column in results only
3.3 Trial Conditions:
3.3.1 Aggregation function AVG (), MAX () ...
3.3.2 Query the value of a column based on a condition
Convert (Universal Transformation Example: convert.string convert.int32 ...)
C # Link Database