Feeds:
Posts
Comments

Recently i encountered with a problem related to fetching the identity value of a table upon insertion.In my one of the old project there was a table with identity column . In the stored procedure i had used “@@IDENTITY ” to fetch the last identity value entered into a table.After sometime i realized that i was not getting the right identity value upon insertion.After a lot of investigation i came to know that a trigger was written on this table for insert.This trigger was for insertion of record in another table with identity column.

I found that after implementation of this trigger whenever record inserted into previous table the stored procedure returns the identity value of the another table in which the record was getting inserted by the trigger.

After a lot of R&D i came to know about “SCOPE_IDENTITY()” and this one solved my problem.

The reason is – “@@IDENTITY “ will return last identity values generated in any table in the current session. So in my case this is the table which is linked with trigger.

So the concept is:

@@IDENTITY will return last identity values generated in any table in the current session. However, SCOPE_IDENTITY() returns values inserted only within the current scope .

How to compare time?

string t1 = DateTime.Parse(“5:45 PM”).ToString(“t”);
string t2 = DateTime.Now.ToString(“t”);

Continue Reading »

string stringUri = “http://www.withoneclick.wordpress.com/?sid=1&fid=16″;

Uri weburi = new Uri(stringUri);

Continue Reading »

Smart Navigation

Smart navigation is a little-known Internet Explorer feature that enables the individual controls on your Web forms to maintain focus between postback, as well as allows you to suppress that flicker that occurs as you load the new page.
To turn on this little-known feature, simply set the smartNavigation property of your ASPX page to True. You can also apply the property to all project pages, by adding the <pages> tag to the following location within your Web.config file:

<configuration>
<
system.web>
<
pages smartNavigation=true/>
</system.web>
</configuration>

Note that smart navigation works on only Internet Explorer 5 and above.

Aspx Part:

<asp:DropDownList ID=”ddlAction” runat=”server”>
<asp:ListItem Value=”0″>Select</asp:ListItem>
<asp:ListItem
Value=”1″>Ask For Postback</asp:ListItem>
</asp:DropDownList>

Cs Part:

ddlAction.Attributes.Add(“onchange”, “return askForPostBack();”);

JavaScript Function:

function askForPostBack()
{
if(document.getElementById(‘<%=ddlAction.ClientID%>’).selectedIndex == 1)
{
var x = confirm(‘Need PostBack?’);
if(x)
{
__doPostBack(document.getElementById(‘<%=ddlAction.ClientID%>’),”);
document.getElementById(‘<%=ddlAction.ClientID%>’).selectedIndex=0;
return true;
}
else
{
document.getElementById(‘<%=ddlAction.ClientID%>’).selectedIndex=0;
return false;
}

}

}

<script language="javascript">

    var dat = new Date();
    var curday = dat.getDate();
    var curmon = dat.getMonth()+1;
    var curyear = dat.getFullYear();

function datediff(date1, date2)
{
    var y1 = date1.getFullYear(), m1 = date1.getMonth(), d1 = date1.getDate(),
    y2 = date2.getFullYear(), m2 = date2.getMonth(), d2 = date2.getDate();
     return [y1 - y2];
}

function calage()
{
    var str1 = document.getElementById(’<%=txtDate.ClientID%>’).value ;

    var mon1 = parseInt(str1.substring(0,2),10);
    var dt1 = parseInt(str1.substring(3,5),10);
    var yr1 = parseInt(str1.substring(6,10),10);

    var calday = parseInt(str1.substring(3,5),10);
    var calmon = parseInt(str1.substring(0,2),10);
    var calyear = parseInt(str1.substring(6,10),10);

    var curd = new Date(curyear,curmon-1,curday);
    var cald = new Date(calyear,calmon-1,calday);
    var diff =  Date.UTC(curyear,curmon,curday,0,0,0) –
                    Date.UTC(calyear,calmon,calday,0,0,0);
    var dife = datediff(curd,cald);

    var x = parseInt(dife);

    if(x<parseInt(18))
    {
      alert(‘Age is less than 18 Years’);
    }
    else
    {
       alert(‘Age is greater than 18 Years’);
    }
}
</script>

var str1 = document.getElementById(‘<%=txtDate1.ClientID%>’).value ;

var str2 = document.getElementById(‘<%=txtDate2.ClientID%>’).value ;

 

var mon1 = parseInt(str1.substring(0,2),10);

var dt1 = parseInt(str1.substring(3,5),10);

var yr1 = parseInt(str1.substring(6,10),10);

 

var mon2 = parseInt(str2.substring(0,2),10);

var dt2 = parseInt(str2.substring(3,5),10);

var yr2 = parseInt(str2.substring(6,10),10);

 

var date1 = new Date(yr1, mon1, dt1);

var date2 = new Date(yr2, mon2, dt2);

 

if(date2 > date1)

{

    alert(‘Date2 is greater than Date1 ‘);

}

Follow

Get every new post delivered to your Inbox.