DataSet ds = new DataSet(); ds = DataSetObject; Session["mySession1"] = ds; DataTable = new DataTable(); dt = DataTableObject; Session("mySession2") = dt; //*** Used Session ***// DataSet ds2; ds2 = Session["mySession1"]; DataTable dt2; dt2 = Session["mySession2"];
System.Data.OleDb.OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(); System.Data.OleDb.OleDbCommand objCmd = new System.Data.OleDb.OleDbCommand(); System.Data.OleDb.OleDbDataAdapter dtAdapter = new System.Data.OleDb.OleDbDataAdapter(); DataSet ds = new DataSet(); DataTable dt; String strConnString,strSQL; strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("database/mydatabase.mdb")+";Jet OLEDB:Database Password=;"; strSQL = "SELECT * FROM customer"; objConn.ConnectionString = strConnString; objCmd.Connection = objConn; objCmd.CommandText = strSQL; objCmd.CommandType = CommandType.Text; dtAdapter.SelectCommand = objCmd; dtAdapter.Fill(ds); dt = ds.Tables[0]; Session["mySession"] = dt; dtAdapter = null; objConn.Close(); objConn = null; //*** BindData to Control ***// DataTable dt2; dt2 = Session["mySession"]; if(Session["mySession"] != null) { this.myDataGrid.DataSource = dt2; this.myDataGrid.DataBind(); }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท