Reset primary key

徘徊边缘 提交于 2019-12-06 06:29:40

i tried it with the autoincrementseed and autoincrementstep and it finally works. here's for the reference of others:

sharedDS.Clear();
sharedDS.Table1.Columns[0].AutoIncrementStep = -1;
sharedDS.Table1.Columns[0].AutoIncrementSeed = -1;
sharedDS.Table1.Columns[0].AutoIncrementStep = 1;
sharedDS.Table1.Columns[0].AutoIncrementSeed = 1;

please see reasoning in this thread: http://www.eggheadcafe.com/community/aspnet/10/25407/autoincrementseed.aspx

and: http://msdn.microsoft.com/en-us/library/system.data.datacolumn.autoincrementseed(VS.85).aspx

thanks all for your help!

Does the DataSet.Clear() method do what you want?

Edit

Because you say you want to reset the primary key, you must be talking about on the DataTables the DataSet holds. Have you tried calling DataSet.Tables["MyTable"].Reset(), which should reset the table to it's original state, rather than the whole DataSet?

Edit 2

If this is an autoincrementing column, have you tried resetting the DataColumn's AutoIncrementSeed property to 0?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!