using System.Web.Caching;
using System.Data.SqlClient;
public partial class MyCaching : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds;
ds = (DataSet)Cache["firmCustomers"];
if (ds == null)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GetitDMConnectionString2"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("Select top 20 areaname, pincode from area", conn);
ds = new DataSet();
da.Fill(ds);
SqlCacheDependency myDependency = new SqlCacheDependency("DMS", "area");
Cache.Insert("firmCustomers", ds, myDependency);
Label1.Text = "Produced From database";
}
else
{
Label1.Text = "Produced From Cache";
}
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
============================
Enabling the Database and Table
d:\program files\microsoft visual studio 9.0\VC>
Run these commands in Command promt On above prompt
aspnet_regsql.exe -S "192.168.0.181" -U sa -P sa123 -d DMS -ed
aspnet_regsql.exe -S "192.168.0.181" -U sa -P sa123 - d DMS -t Userlogin -et
====================================
//webconfig
Symbols
LL => Less Than
GG => Greater Than
< connectionStrings >
< add name="GetitDMConnectionString2" connectionString="Data Source=192.168.0.181;Initial Catalog=DMS;Persist Security Info=True;User
ID=sa;Password=sa123;Connect Timeout=900; pooling='true';Max Pool Size=200" providerName="System.Data.SqlClient"/ >
< /connectionStrings >
< system.web >
< caching >
< sqlCacheDependency enabled="true" >
< databases >
< add name="DMS" connectionStringName="GetitDMConnectionString2" pollTime="500" / >
< /databases >
< /sqlCacheDependency >
< /caching >
Wednesday, September 23, 2009
using System.Web.Caching;
using System.Data.SqlClient;
public partial class MyCaching : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds;
ds = (DataSet)Cache["firmCustomers"];
if (ds == null)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GetitDMConnectionString2"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("Select top 20 areaname, pincode from area", conn);
ds = new DataSet();
da.Fill(ds);
SqlCacheDependency myDependency = new SqlCacheDependency("DMS", "area");
Cache.Insert("firmCustomers", ds, myDependency);
Label1.Text = "Produced From database";
}
else
{
Label1.Text = "Produced From Cache";
}
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
=======================
Enabling the Database and Table
d:\program files\microsoft visual studio 9.0\VC>
Run these commands in Command promt On above prompt
aspnet_regsql.exe -S "192.168.0.181" -U sa -P sa123 -d DMS -ed
aspnet_regsql.exe -S "192.168.0.181" -U sa -P sa123 - d DMS -t Userlogin -et
========================
//webconfig
Symbols:
LL Means Less Than
GG Means Greater Than
using System.Data.SqlClient;
public partial class MyCaching : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds;
ds = (DataSet)Cache["firmCustomers"];
if (ds == null)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GetitDMConnectionString2"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("Select top 20 areaname, pincode from area", conn);
ds = new DataSet();
da.Fill(ds);
SqlCacheDependency myDependency = new SqlCacheDependency("DMS", "area");
Cache.Insert("firmCustomers", ds, myDependency);
Label1.Text = "Produced From database";
}
else
{
Label1.Text = "Produced From Cache";
}
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
=======================
Enabling the Database and Table
d:\program files\microsoft visual studio 9.0\VC>
Run these commands in Command promt On above prompt
aspnet_regsql.exe -S "192.168.0.181" -U sa -P sa123 -d DMS -ed
aspnet_regsql.exe -S "192.168.0.181" -U sa -P sa123 - d DMS -t Userlogin -et
========================
//webconfig
Symbols:
LL Means Less Than
GG Means Greater Than
Friday, September 18, 2009
Use of Case when Statement with multiple condition
SELECT distinct city,
(CASE city
WHEN 'Delhi' THEN '11'
WHEN 'chennai' THEN '22'
ELSE '33'
END) as STDCode
from area
(CASE city
WHEN 'Delhi' THEN '11'
WHEN 'chennai' THEN '22'
ELSE '33'
END) as STDCode
from area
Tuesday, August 11, 2009
Select All Checkbox on Click of One checkbox in Javascript
==Script in Javascript===
function SelectAllCheckboxes(spanChk)
{
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var theBox= (spanChk.type=="checkbox") ?
spanChk : spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
{
if(elm[i].checked!=xState)
elm[i].click();
}
}
==Check all checkbox on selection of A Checkbox
input id="Checkbox2" type="checkbox" onclick="javascript:SelectAllCheckboxes(this);" / Check All
function SelectAllCheckboxes(spanChk)
{
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var theBox= (spanChk.type=="checkbox") ?
spanChk : spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i
{
if(elm[i].checked!=xState)
elm[i].click();
}
}
==Check all checkbox on selection of A Checkbox
input id="Checkbox2" type="checkbox" onclick="javascript:SelectAllCheckboxes(this);" / Check All
Clear the Controls Data on Click of Reset Button
I have 20 controls on my web page. I want to clear the controls data when onclick of reset button:
private void ClearControls(Control parent)
{
foreach (Control _ChildControl in parent.Controls)
{
if ((_ChildControl.Controls.Count > 0))
{
ClearControls(_ChildControl);
}
else
{
if (_ChildControl is TextBox)
{
((TextBox)_ChildControl).Text = string.Empty;
}
else
if (_ChildControl is CheckBox)
{
((CheckBox)_ChildControl).Checked = false;
}
else
if (_ChildControl is DropDownList)
{
((DropDownList)_ChildControl).SelectedIndex = 0;
}
else
if (_ChildControl is ListBox)
{
((ListBox)_ChildControl).SelectedIndex = 0;
}
}
}
}
calling this function like this:pn click of reset button
ClearControls(this.Page);
private void ClearControls(Control parent)
{
foreach (Control _ChildControl in parent.Controls)
{
if ((_ChildControl.Controls.Count > 0))
{
ClearControls(_ChildControl);
}
else
{
if (_ChildControl is TextBox)
{
((TextBox)_ChildControl).Text = string.Empty;
}
else
if (_ChildControl is CheckBox)
{
((CheckBox)_ChildControl).Checked = false;
}
else
if (_ChildControl is DropDownList)
{
((DropDownList)_ChildControl).SelectedIndex = 0;
}
else
if (_ChildControl is ListBox)
{
((ListBox)_ChildControl).SelectedIndex = 0;
}
}
}
}
calling this function like this:pn click of reset button
ClearControls(this.Page);
Monday, August 10, 2009
C# Conditions in 2 different ways
Checking condition in 2 different way
One Way is
if (item.Text.ToString() == "Professional")
query1 = "P";
else
query1 = "C";
--------
query1 = item.Text.ToString() == "Professional" ? "P" : "C";
================Separate
if (item.Selected == true)
query1 = item.Text.ToString() == "Professional" ? "P" : "C";
---------
if (item.Selected != true) continue;
query1 = item.Text.ToString() == "Professional" ? "P" : "C";
One Way is
if (item.Text.ToString() == "Professional")
query1 = "P";
else
query1 = "C";
--------
query1 = item.Text.ToString() == "Professional" ? "P" : "C";
================Separate
if (item.Selected == true)
query1 = item.Text.ToString() == "Professional" ? "P" : "C";
---------
if (item.Selected != true) continue;
query1 = item.Text.ToString() == "Professional" ? "P" : "C";
Tuesday, August 4, 2009
Referencing Blogs
http://7explications.wordpress.com/
http://sajithpremachandran.blogspot.com/
http://sajithpremachandran.wordpress.com/
http://sairamjvh.blogspot.com/
http://arrao4u.wordpress.com/
http://aspdotnetcodebook.blogspot.com/
http://sajithpremachandran.blogspot.com/
http://sajithpremachandran.wordpress.com/
http://sairamjvh.blogspot.com/
http://arrao4u.wordpress.com/
http://aspdotnetcodebook.blogspot.com/
Complete basic Tutorial of WCF
Subscribe to:
Posts (Atom)