類代碼
using System;
using System
using System
namespace exchange
{
public class MyDataOp
{
private String StrSql;
private String StrConn;
private SqlConnection Conn;
public MyDataOp(String ss)
{
StrSql = ss;
StrConn = System
}
public SqlDataReader CreateReader()
{
Conn=new SqlConnection(StrConn);
SqlCommand Comm=new SqlCommand(StrSql
Conn
SqlDataReader MyReader = Comm
return MyReader;
}
public DataSet CreateDataSet()
{
Conn=new SqlConnection(StrConn);
Conn
SqlDataAdapter Adpt=new SqlDataAdapter(StrSql
DataSet Ds=new DataSet();
Adpt
return Ds;
}
public SqlCommand ExecuteCommand()
{
Conn=new SqlConnection(StrConn);
SqlCommand Comm=new SqlCommand(StrSql
Conn
Comm
return Comm;
}
public void Close()
{
Conn
}
}
}
基本用法
namespace exchange
{
using System;
using System
using System
using System
using System
using System
using System
public class newjoin : System
{
protected DataList newjoinlist;
public newjoin()
{
this
}
protected void Page_Load(object sender
{
if(!IsPostBack)
{
LoadData();
}
}
protected void LoadData()
{
String StrSql =
MyDataOp mdo = new MyDataOp(StrSql);
DataSet ds = mdo
newjoinlist
newjoinlist
mdo
}
private void Page_Init(object sender
{
InitializeComponent();
}
private void InitializeComponent()
{
this
}
}
}
From:http://tw.wingwit.com/Article/os/xtgl/201311/9476.html