auto-genrate id using table
protected void generatedStudID()
{
cn = new SqlConnection(cs);
cn.Open();
int a=1;
string k1 = "select * from patientreg where sno='" + a + "'";
cm = new SqlCommand(k1, cn);
dr = cm.ExecuteReader();
if (dr.Read())
{
dr.Close();
cm = new SqlCommand("select MAX(sno) from TABLE", cn);
int i = Convert.ToInt32(cm.ExecuteScalar());
cn.Close();
i++;
Labelpid.Text = "PA-" + DateTime.Now.ToString("yyyy") + "-00-" + i.ToString();
dr.Close();
}
else
{
dr.Close();
Labelpid.Text = "PA-" + DateTime.Now.ToString("yyyy") + "-00-" + "1";
}
dr.Close();
}
{
cn = new SqlConnection(cs);
cn.Open();
int a=1;
string k1 = "select * from patientreg where sno='" + a + "'";
cm = new SqlCommand(k1, cn);
dr = cm.ExecuteReader();
if (dr.Read())
{
dr.Close();
cm = new SqlCommand("select MAX(sno) from TABLE", cn);
int i = Convert.ToInt32(cm.ExecuteScalar());
cn.Close();
i++;
Labelpid.Text = "PA-" + DateTime.Now.ToString("yyyy") + "-00-" + i.ToString();
dr.Close();
}
else
{
dr.Close();
Labelpid.Text = "PA-" + DateTime.Now.ToString("yyyy") + "-00-" + "1";
}
dr.Close();
}