If their is any failure in retreiving data from database then what is jobid...?
Use this code..
public void CalculateJOBID()
{
DataTable mdt = new DataTable();
int jobid=0;
string qry = "select id as id ,jobid as jid from Jobsheet where id = (select max(id) from Jobsheet where date='"+ DateTime.Now.Date +"')";
mdt = SQLobj.SQL_Adapter(qry);
if (mdt.Rows.Count == 0)
jobid=1;
else
{
string jid = mdt.Rows[0]["jid"].ToString();
jobid = Convert.ToInt32(jid);
if (mdt.Rows.Count > 0)
{
jobid = jobid + 1;
}
}
txt_jobid.Text = jobid.ToString();
}