Use the debugger - it's the only way to find out what is going on. We can't run your code under the same conditions, so we really can't tell you "do this".
Put a breakpoint on the line
str = ConfigurationManager.ConnectionStrings["WEBHR"].ConnectionString;
And when it reaches it the debugger will stop. Single step each line, looking closely at each variable and follow exactly what is happening. You should be able to work it out for yourself from that, but if you still can't, at least you will have information to give us to help us work it out. At the moment, all you have is "it don't work" which helps no-one!
BTW: I'd strongly suggest that you use
using
blocks around your SQl objects, to ensure they are closed and disposed correctly:
try
{
string str;
str = ConfigurationManager.ConnectionStrings["WEBHR"].ConnectionString;
using (SqlConnection sqlCon = new SqlConnection(str))
{
using (SqlCommand sqlCmd = new SqlCommand("sp_GenerateLeaveID", sqlCon))
{
sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
string intno,intno1,intno2;
intno2 = txt_idcnt.Text;
if (intno2 == "")
{
lblstatus.Text = "No record Selected";
}
sqlCmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
lblstatus.Text = ex.Message;
}