日期:2014-05-16  浏览次数:21111 次

VC++ ADO连接可以执行alter语句吗
代码如下:
_CommandPtr   m_pCommand_alter;

m_pCommand_alter.CreateInstance(__uuidof(Command));
m_pCommand_alter-> ActiveConnection   =   m_pConnection;
m_pCommand_alter-> CommandText   =   "alter   table   table1   alter   column   id   COUNTER   (1,   1) ";
m_pCommand_alter-> Execute(NULL,   NULL,adCmdText);

表table1的id字段是一个自增字段,我希望每次从1开始递增,于是写了这条alter语句,但是每次执行时都非正常终止,用try   catch也捕获不到。非常费解,请大家指点一下!非常感谢!
我的数据库是Access   2003   SP2英文版。

------解决方案--------------------
这种方式要求表中没有数据,你可以先备份->删除数据->修改->导入数据
------解决方案--------------------
alter table table1 alter column [id] COUNTER (1, 1)
试试,SQL语句没有问题
------解决方案--------------------
在ACCESS中测试没有问题
------解决方案--------------------
在执行前,确保表中没有数据。

提示什么错误?
------解决方案--------------------
alter table 表名 alter column [id] counter(1,1)

--或

alter table 表名 alter column [id] AutoIncrement(1,1)