private DataSet bindCachedData()
{
string sql = "SELECT * FROM np_pucm_refresh_cal";
constr = "user id=NPUSER;data source=PNPSCAL;password=NPUSER;Min Pool
Size=1;Connection Lifetime=0;Connection Timeout=60;Incr Pool
Size=1;Decr Pool Size=1;";
DataSet ds;
ds = (DataSet)Cache.Get("UserTable");
if (ds ==null)
{
lblMsg.Text = "Data fetched from Table";
using (OracleConnection con = new OracleConnection(constr))
{
con.Open();
using (OracleCommand cmd = new OracleCommand(sql, con))
{
OracleDependency dep = new OracleDependency(cmd);
cmd.Notification.IsNotifiedOnce = false;
dep.OnChange += new OnChangeEventHandler(OnMyNotificaton);
OracleDataAdapter da = new OracleDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
Cache.Insert("UserTable", ds);
}
}
}
else
lblMsg.Text = "Data fetched from Cache";
return ds;
}
public void OnMyNotificaton(object src, OracleNotificationEventArgs arg)
{
DataTable changeDetails = arg.Details;
Cache.Remove("UserTable");
lblMsg.Text = "Data fetched from Table";
}
protected void Timer1_Tick(object sender, EventArgs e)
{
GridView1.DataSource = bindCachedData();
GridView1.DataBind();
}
Thursday, June 23, 2011
Wednesday, June 15, 2011
Import a div's content into excel using javascript
Call the bellow js function "OnClientClick" event of a button
<script language="javascript" type="text/javascript">
function ABC() {
var strCopy = document.getElementById('calendar').innerHTML;
window.clipboardData.setData("Text", strCopy);
var objExcel = new ActiveXObject("Excel.Application");
objExcel.visible = true;
var objWorkbook = objExcel.Workbooks.Add;
var objWorksheet = objWorkbook.Worksheets(1);
objWorksheet.Paste;
return false;
}
</script>
<script language="javascript" type="text/javascript">
function ABC() {
var strCopy = document.getElementById('calendar').innerHTML;
window.clipboardData.setData("Text", strCopy);
var objExcel = new ActiveXObject("Excel.Application");
objExcel.visible = true;
var objWorkbook = objExcel.Workbooks.Add;
var objWorksheet = objWorkbook.Worksheets(1);
objWorksheet.Paste;
return false;
}
</script>
Subscribe to:
Posts (Atom)