Mobasir Hossain

Mobasir Hossain

  • NA
  • 79
  • 1.2k

Highest value reading Data Base Coloumn

May 24 2018 1:07 AM
Hello,
 
 I am using bellow command to check max value of column .It works upto 10 after that it  sends always 10 though my data base already increased upto 13 rows.
 
I also checked  SELECT ISNULL (MAX(ID)+1,0)
                            SELECT ISNULL (MAX(ID),0)
 
Please suggest me what to do. 
SqlCommand cmd = new SqlCommand("SELECT ISNULL (MAX(ID)+1,1) AS Result FROM CustomerDetail", con);
 
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
id = dr[0].ToString();
id = (Convert.ToInt64(id) + 1).ToString();
}
}
 
 
 

Answers (2)