Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2005 SQL Server 2005 CE 3.5重新设定种子标识_Sql Server 2005_.net 3.5_Sql Server Ce - Fatal编程技术网

Sql server 2005 SQL Server 2005 CE 3.5重新设定种子标识

Sql server 2005 SQL Server 2005 CE 3.5重新设定种子标识,sql-server-2005,.net-3.5,sql-server-ce,Sql Server 2005,.net 3.5,Sql Server Ce,我已经在数据表中插入了一些行 设置标识\u插入tblEvent on 然后,我尝试“重新设置”标识字段的种子 int MaxId = this.MaxID()+1; string upgrade = "ALTER TABLE " + Table + " ALTER COLUMN ID IDENTITY("+ MaxId.ToString() +",1)"; System.Data.SqlServerCe.SqlCeCommand cmd = new System.Data.SqlServerCe

我已经在数据表中插入了一些行

设置标识\u插入tblEvent on

然后,我尝试“重新设置”标识字段的种子

int MaxId = this.MaxID()+1;
string upgrade = "ALTER TABLE " + Table + " ALTER COLUMN ID IDENTITY("+ MaxId.ToString() +",1)";
System.Data.SqlServerCe.SqlCeCommand cmd = new System.Data.SqlServerCe.SqlCeCommand(upgrade, connection);
cmd.CommandType = System.Data.CommandType.Text;
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
“MaxId”由

int MaxId = 0;
string upgrade = "select Max(ID) from " + Table;
System.Data.SqlServerCe.SqlCeCommand cmd = new System.Data.SqlServerCe.SqlCeCommand(upgrade, connection);
cmd.CommandType = System.Data.CommandType.Text;
connection.Open();
MaxId = (int)cmd.ExecuteScalar();
connection.Close();
return MaxId;
但是,如果我在设定种子后再次查询MaxID,它并没有改变 任何想法都是正确的

试试这个:

string upgrade = " DBCC CHECKIDENT('[" + Table + "]', RESEED, " + (MaxId + 1)+ " )"

奇怪,可能是权限问题。不过,您应该已经看到了一个异常,除非该异常被一个“包罗万象”所吞噬。

谢谢,我还以为CE3.5不支持DBCC呢?