Thursday, October 18, 2012

Update Top 1 row in Sql Server

Update Top (1) Tab_Test set name='' where serialNum=1

Sunday, October 14, 2012

Set Sql Server Time Out in ASP.Net

How to Solve timeout expired problem:

simply Add in your web.config file inside ConnectionString;
<connectionStrings>
<add name="connect" connectionString="DataSource=MYPC;Initial Catalog=North;TimeOut=120"/>
</connectionStrings>
If u use a SqlCommand object in your code:
Then use

SqlCommand cmd=new SqlCommand();
cmd.TimeOut="180";

Sunday, September 16, 2012

Automatically Refresh Page in ASP.NET

Simply Add a meta tag in design code inside header tag

<meta http-equiv="refresh" content="15" /> 

Monday, August 27, 2012

READ AND WRITE COOKIES IN ASP.NET

 At Page load event


//////Read Cookie
 if(Request.Cookies["Cookiename"]!=null)
{
HttpCookie cok=new HttpCookie("Cookiename");
LblCookie.Text=cok.Value ;
}
//////



/////write cookie

HttpCookie cok=new HttpCookie("Cookiename");
cok.Value=txtUsername.Text;
Response.Cookies.Add(cok);



//////

Sunday, August 12, 2012

Character Count in asp.net


Define Script in design side

 <script type="text/javascript">
 
        function textCounter(field, countfield, maxlimit,msg,word)
        {
           if (field.value.length > maxlimit)
               field.value = field.value.substring(0, maxlimit);
           else
           {
               countfield.value =maxlimit - field.value.length;
               word.value=field.value.length;
               if(word.value > 160  && word.value <= 321)
                msg.value="2";
                else if(word.value > 321 && word.value <= 482)
                   msg.value="3";
                 
                    else if(word.value > 482 && word.value <= 643)
                   msg.value="4";
                 
                    else if(word.value > 643 && word.value <= 800)
                   msg.value="5";
                 
                   else
                         msg.value="1";
               
           }
        }
 
  </script>




<asp:TextBox ID="TxtMessage" runat="server" Height="92px"
            onkeydown="textCounter(this, this.form.countLen, 800,this.form.msgcount,this.form.wcount);"
            onkeyup="textCounter(this, this.form.countLen, 800,this.form.msgcount,this.form.wcount);" TextMode="MultiLine"></asp:TextBox>


<input maxlength="3" name="countLen" readonly="readonly" size="3"
            style="width: 26px; height: 16px;" type="text" value="800"
            style="border:none; border-color:White; background-color:White;" />Characters Left<br />
        <font color="red">
        Total
           
      <input name="wcount" value="0" type="text" readonly="readonly"
           
           
            style="border:medium none White; background-color:White; width: 24px; height: 15px; color:Red;" />Word(s)
        and&nbsp;<input name="msgcount" value="0" type="text" readonly="readonly"
            style="border:medium none White; background-color:White; width: 14px; height: 15px; color:Red;" />Message(s)

Saturday, June 16, 2012

How To Set Default focus and default button click

 <form id="form1" runat="server" defaultbutton="Btn_Log" defaultfocus="txtUname">

</form>

Monday, May 7, 2012

Create Table from another Table in SQL SERVER

select * into Newtable from oldtable where name like 'a%'

 Above query create table with name Newtable and copy all data from oldtable,


I f u want to create only structure as same as old table then you
can use :

WHERE 1=2

select * into   Newtable from oldtable where 1=2