获取某个表中的ID,得到下一个ID值
public string GetID()
{
object MaxId = null;
string id = "";
try
{
String sql = "select Max(Convert(int,ID)) from Table";
MaxId = DataClass.GetOneValue(getConnectionString(), sql);
if (MaxId != null && MaxId.ToString().Trim() != "")
{
int lenght = MaxId.ToString().Length;
id = Convert.ToString(Convert.ToInt32(MaxId.ToString().Trim()) + 1);
for (int i = 0; i < 6 - lenght; i++)
{
id = "0" + id;
}
}
else
{
id = "000001";
}
}
catch (Exception ex)
{
throw ex;
}
return id;
}