Try below Code
In Sql
Create proc [dbo].[SP_Name]
as
select ISNULL (MAX(AdmissionNo),0)+1 from TableName
return
In Class File
public DataSet GetOrderIDUniqueMax()
{
DataSet ds = new DataSet();
cmd = new SqlCommand("SP_Name", obj_con.Obj_ConLink);
cmd.CommandType = CommandType.StoredProcedure;
da = new SqlDataAdapter(cmd);
da.Fill(ds);
return ds;
}
Code Behind
ClassName ObCls = new ClassName
public void ORderIDGenearate()
{
ds = obCls.GetOrderIDUniqueMax();
lblMaxIdForOrder.Text = ds.Tables[0].Rows[0][0].ToString();
}
_AdmissionNo = "R-" + lblMaxIdForOrder.Text;
Ouput id
R-0001