: Http://www.bkjia.com/uploadfile/2012/0328/20120328090222134.rar
GetCOn static class
Public string getCon. connectionString (string configConnectionStringsName, out string provider)
Obtain database connection characters from web. Config
DataOperate class
Constructor public DataOperate (string provider, string cons, string outer web)
Method
Public int excuteCommand (string str)
Execute the SQL statement and return the affected number of rows.
Public int excuteCommand (string str, SqlParameter [] parameter)
Execute the SQL statement and return the affected number of rows.
Public void excuteCommand (string str, out string scalar)
Execute the SQL statement. The value of scalar in the first column of the First Line
Public DataSet getDataset (string str, string tableName)
Execute the SQL statement and return the DataSet object
Public IDataReader getDataReader (string str)
Execute the SQL statement and return the IDataReader object.
Public IDataReader getDataReader (string str, SqlParameter [] parameter)
Execute the SQL statement and return the IDataReader object.
Public void Close ()
Close the connection to the database
Public void Open ()
Open Database Connection
Example: providerName only supports oledb, sqlclient, and oracleclient strings
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using CommDataOperate;
Public partial class Default2: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
String provider;
String con = getCon. connectionString ("examSystem", out provider );
DataOperate data = new DataOperate (provider, con, "www.cnblogs.com/lifeofit ");
Data. Open ();
GridView1.DataSource = data. getDataReader ("select * from instructor information table ");
GridView1.DataBind ();
Data. Close ();
}
}
From the blue Pavilion