First, SQL syntax
1. Query Statement Select
SELECT * FROM table name where query condition
2. Delete statements
Delete table name where delete condition
3. INSERT statement Inserts
Insert into table name (Field 1, Field 2) VALUES (' Value 1 ', ' Value 2 ')
4. Modify Statement Update
Update table name Set field = new value where modify condition
5. SQL statement Operations Database and table
drop table name//delete data table
Create DATABASE Database name//databases created
Drop database name//delete data bitter
ALTER TABLE name add field name data type//data table added field
ALTER TABLE Name drop column field name//Data table Delete field
ALTER TABLE name ALTER COLUMN field name new data type//modify field data type
Second, the use of the ADO object
1. SqlConnection class: Create a Database link object
SqlConnection conn=new SqlConnection ("server= server name; uid= user; pwd= password; database= database name");
2. SqlCommand class: The object that executes the SQL statement
SqlConnection conn=new SqlConnection ("server= server name; uid= user; pwd= password; database= database name");
String cmdstr= "select * from Student";
SqlCommand cmd=new SqlCommand (Cmdstr,con);
3. SqlDataReader class: Create an object that queries one or more data
SqlConnection conn=new SqlConnection ("server= server name; uid= user; pwd= password; database= database name");
String cmdstr= "select * from Student";
SqlCommand cmd=new SqlCommand (Cmdstr,con);
SqlDataReader Reader=cmd. ExecuteReader ();
4. SqlDataAdapter class: Create an object to retrieve and persist data
SqlConnection conn=new SqlConnection ("server= server name; uid= user; pwd= password; database= database name");
String cmdstr= "select * from Student";
SqlCommand cmd=new SqlCommand (Cmdstr,con);
SqlDataAdapter Adapter=new SqlDataAdapter (CMD);
5. DataSet class: Create a local data store object
SqlConnection conn=new SqlConnection ("server= server name; uid= user; pwd= password; database= database name");
String cmdstr= "select * from Student";
SqlCommand cmd=new SqlCommand (Cmdstr,con);
SqlDataAdapter Adapter=new SqlDataAdapter (CMD);
DataSet ds=new DataSet ();
Adapter. Fill (DS);
This article from the "Search in the Wind" blog, declined to reprint!
SQL syntax and ADO summary