Id的增加

时间:2016-09-23 01:43:58

标签: c# sql asp.net sql-server

id将增加1,例如00001.但每当我插入新数据时,增量将重新开始。我希望它从最后一次增量继续。

查询

string GetMaxIdSql =
@"select isnull(Max(convert(int, ApplicationId)),0) as ApplicationId, isnull(Max(convert(int, Id)),0) as Id from Application where isnumeric(id) = 1 and isnumeric(applicationid) = 1"; 

命令

resultMaxId.Id = (Convert.ToInt32(resultMaxId.Id) + 1).ToString();         
string id = string.Format("{0}", resultMaxId.Id.ToString().PadLeft(6, '0'));

1 个答案:

答案 0 :(得分:0)

请检查ApplicationId和Id列中的完整数据。可能有一些字符导致了这个问题。

相关问题