DataSet ds; ds=null; if (refresh==true||Session["COLLIGATE_MONTH1"]==null) { string sql; if (this.TextBox1.Text=="" ) { sql="select top 600 * from COLLIGATE_MONTH1 "; } else { sql="select * from COLLIGATE_MONTH1 where telnum='"+this.TextBox1.Text+"'";//+" order by db_time desc"; }
ds=null;
if (refresh==true||Session["COLLIGATE_MONTH1"]==null)
{
string sql;
if (this.TextBox1.Text=="" )
{
sql="select top 600 * from COLLIGATE_MONTH1 ";
}
else
{
sql="select * from COLLIGATE_MONTH1 where telnum='"+this.TextBox1.Text+"'";//+" order by db_time desc";
}
this.sqlConnection1.Open();//.sqlConnection1.Open(); SqlDataAdapter mycommand =new SqlDataAdapter(sql ,this.sqlConnection1);
ds=new DataSet();
mycommand.Fill(ds,"COLLIGATE_MONTH1");
Session["COLLIGATE_MONTH1"]=ds;
this.sqlConnection1.Close();
OleDbConnection myConn = new OleDbConnection ( strCon ) ;
myConn.Open ( ) ;
////////////////////////////////////我的方法是:
1.加一个类方法
private void init()
{
this.sqlDataAdapter1.Fill(this.dataSet11,"Employees");
}
2.在form1的构造函数中加上:
init(); //加在InitializeComponent();的后面
//
//这个方法我在winform中是实现了的。