如何使用vb.net截断访问数据库表 [英] How to truncate the table of access database using vb.net

查看:103
本文介绍了如何使用vb.net截断访问数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,我在vb.net中有一个要求。我想删除访问数据库表中的记录。如果我想从起点插入记录。但在该表中是标识列。记录不是从起始位置插入的。如果我在vb.net中写了Truncate查询。我在程序中遇到错误。



错误是:无效的SQL语句;预期'删除','插入','过程','选择'或'更新'。



请帮助我...

Hi friends, I have a requirement in vb.net . I want to delete the records in table of access database. If i want to insert the records from starting point. But in that table is identity column. records are not inserted from starting position. If i wrote the Truncate query in vb.net .I got the error in program.

error is : Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.

Please Help me...

推荐答案

没有起点这样的东西,在这个意义上也不是截断语句。那些是DBase概念。

我假设你有一个相当古老的Access - 根据我的经验,在某些版本之前,自动编号字段只有2个字节宽,因此最多只能创建65565条记录。目前有4个字节,因此你有一个相当大的数字 - 所以我认为你不需要重置编号。

但是你可以删除记录,如果你认为你的表太大了。但是新插入的记录将继续自动编号,您无法重复使用它们。如果你需要这样的东西,你需要一个不是自动编号的字段,你必须自己编写编号逻辑 - 如果涉及并发连接,这可能会很复杂。
There is no such thing as "starting point", neither is a "truncate statement" in this sense. Those are DBase concepts.
I assume you have a quite old Access - according to my experience, some versions ago the autonumber fields were only 2 bytes wide, thus enabling only a maximum of 65565 records. Currently there are 4 bytes, thus you have a quite large number - so I don't think you need to reset the numbering.
You can however delete records, if you think your table became too large. But the newly inserted records will continue with the autonumbering, you can not reuse them. If you need such thing, you will need a field that is not autonumbered, and you have to do the numbering logic yourself - which can be complicated with access if there are concurrent connections involved.


我想你要截断表,因为需要重置密钥字段的自动编号属性(MS SQL服务器中的标识)。 MS Access中没有任何功能,但有几种方法可以实现这一点。您可以在此处找到更多相关信息:如何重置Access中的自动编号字段值 [ ^ ]
I think you want to truncate table because of need to reset autonumber property for key field (identity in MS SQL server). There is no functionality in MS Access, but there are several ways to achieve that. More about it you'll find here: How to reset an AutoNumber field value in Access[^]


这篇关于如何使用vb.net截断访问数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆