既然都提到了这个类GetDataTable
干脆把它贴出来,供和我一样的技术小鸟参考
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// GetDataTable 的摘要说明
/// </summary>
public class GetDataTable
{
public GetDataTable()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
SqlConnection dtcon = dataconn.conn();
public DataTable GetData(string sql)
{
// dataconn dtc = new dataconn();
dtcon.Open();
SqlDataAdapter sdt = new SqlDataAdapter(sql,dtcon);
DataTable dt = new DataTable();
sdt.Fill(dt);
return dt;
}
public int DataUpdate(string UpdateSel)
{
int cou;
dtcon.Open();
SqlCommand cmd = new SqlCommand(UpdateSel,dtcon);
cou = cmd.ExecuteNonQuery();
return cou;
}
public bool DataClose()
{
if (dtcon.State == ConnectionState.Open)
{
dtcon.Close();
return false;
}
else
return true;