A brief introduction to a portable database operation component

Source: Internet
Author: User

: 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
 

Related Article

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.