6、using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace dbo.
7、sql
{
public class BaseClass:System.Web.UI.Page
{
String strConn;
public BaseClass()
{
strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
}
//ReadTable方法:從數(shù)據(jù)庫中讀取數(shù)據(jù),并返回一個(gè)DataTable對象
pub
8、lic DataTable ReadTable(String strSql)
{
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection(strConn);
con.Open();
SqlDataAdapter cmd = new SqlDataAdapter(strSql, con);
cmd.Fill(dt);
con.Close();
9、
return dt;
}
//ReadDataSet方法:從數(shù)據(jù)庫中讀取數(shù)據(jù),并返回一個(gè)DataSet對象
public DataSet ReadDataSet(String strSql)
{
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection(strConn);
con.Open();
SqlDataAda
11、new DataSet();
SqlConnection con = new SqlConnection(strConn);
con.Open();
SqlDataAdapter cmd = new SqlDataAdapter(strSql, con);
cmd.Fill(ds, tableName);
con.Close();
return ds;
}
//readrow方法:執(zhí)行SQL查詢,并返
12、回一個(gè)Reader對象
public SqlDataReader readrow(String sql)
{
SqlConnection con = new SqlConnection(strConn);
con.Open();
SqlCommand com = new SqlCommand(sql, con);
SqlDataReader reader = com.ExecuteReader();
if (reader.Read
14、Sql, int flag)
{
DataSet ds = new DataSet();
String str;
SqlConnection con = new SqlConnection(strConn);
con.Open();
SqlDataAdapter cmd = new SqlDataAdapter(strSql, con);
cmd.Fill(ds);
str = ds.Tables
15、[0].Rows[0].ItemArray[flag].ToString();
con.Close();
return str;
}
//execsql方法:用來執(zhí)行SQL更新語句
public Boolean execsql(String strSql)
{
SqlConnection con = new SqlConnection(strConn);
SqlCommand com = new SqlCommand