本文介绍了我们数据库的自动增量ID意味着我想维护例如的id号序列。 1,2,3,4,5等。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 先生,我在ac#windows应用程序中工作, i需要帮助,当我在datagridview中显示记录时,我想要那个 并记住在我的SQL中数据库ID是自动增量,当我删除任何行时, ...之后我想维护例如的id号序列。 1,2,3,4,5等...我删除了2个id记录然后将第3个记录移动到2个位置,第4个记录移动到第3个位置,第5个记录移动到4个位置....它可能是否发生如果是的话怎么办???? sir i am working in a c# windows application,i need help that in when i am showing records in datagridview then i want thatand remember that in my SQL database ID is auto increment,when i delete any row... after that i want maintain the sequence of id number for eg. 1,2,3,4,5 and so on... i delete the 2 id record then move the third record on 2 position, 4th record move on 3rd position, and 5th record move on 4 position.... it may be happen or not if yes how to do that????推荐答案 //maintain one static CustomId variable for Manually increment.Static int CustomId = 0;//When Entering new Record...List<int> DeletedIDs = new List<int>();//Get DeletedId list from DeletedIDTable.DeletedIDs = GetDeletedIds_From_DeletedIdTable().ToList();if(DletedIDs.count > 0) // if list has DeletedIDs then assign that ID to new Record{ //assign DeletedID[0] to new Record. //Remove DeletedID[0] from DeletedIDTable.}else{ //increse your CustomId. CustomId++; //assign this CustomID to new Record} 希望这个帮助你 -------------------- - Pratik Bhuva Hope This Help You---------------------Pratik Bhuva SELECT ROWNUM, ID, NAME, SALARY FROM EMPWHERE ROWNUM < 5 ROWNUM ID NAME SALARY ---------- --------- ------ --------- - 1 100 JOHN 2300 2 110 MILLER 3900 3 120 KATE 4500 4 100 TIM 4200 ROWNUM ID NAME SALARY---------- --------- ------ ---------- 1 100 JOHN 2300 2 110 MILLER 3900 3 120 KATE 4500 4 100 TIM 4200 这篇关于我们数据库的自动增量ID意味着我想维护例如的id号序列。 1,2,3,4,5等。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 12:15