ADO数据库表布尔列 [英] ADO Database Table Boolean Column

查看:99
本文介绍了ADO数据库表布尔列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用ADO时遇到了麻烦。我已经部署了一个使用Access的数据库应用程序。随着不同版本的发布,数据库表具有不同的字段,一些添加了其他字段,等等。我无法使用的是如何在数据库中添加BOOLEAN字段。

I am having a bit of trouble with ADO. I have deployed a database application, which uses Access. With the release of different versions database tables have different fields, some added others deleted etc. What I can't get to work is how to add a BOOLEAN field in the database.

出于升级目的,我将标准的SQL查询组件与如下所示的sql一起使用:

For upgrade purposes I use the standart sql query component with a sql that looks like this :

ALTER TABLE XXX ADD COLUMN YY BOOLEAN

但这适用于其他数据类型,例如VARCHAR,INTEGER,DOUBLE等,但不适用与BOOLEAN。我怀疑这是Access的错,因为它是布尔值,是/否,但是谁知道。

while this works for other data types, such as VARCHAR, INTEGER, DOUBLE etc, it does not with BOOLEAN. I suspect it's Access's fault with it's YES/NO thing for boolean, but who knows.

此外,如何使用TADOTable向表中添加字段?

Also how can I add fields to a table using TADOTable?

预先感谢。

推荐答案

在Microsoft Access SQL中,BIT列直接对应于是/否字段。如果您以后尝试将其转换为SQL Server,我会遇到一种奇怪的行为,我的建议是执行以下操作:

In Microsoft Access SQL, The BIT column directly corresponds to the YES/NO field. I have experienced an odd behavior with it if you attempt to convert this later to SQL Server, and my advise is to then do the following:

每次进行检查时,针对此字段,请记住语法为(FIELD<> 0)用于检查TRUE,以及(FIELD = 0)用于检查false。 SQL Server不了解TRUE / FALSE的概念,在访问时,该值返回-1和0,而在SQL Server中,该值返回1和0。

When EVER you do a check against this field, remember the syntax should be (FIELD <> 0) for checking TRUE, and (FIELD = 0) for checking false. SQL Server doesn't understand the concept of TRUE/FALSE, and in access the value returns -1 and 0, while in SQL Server the values are 1 and 0.

在访问中,如果您还将字段设置为非null,它将仅显示一个复选框。如果允许使用null,则它将显示0或-1或为空。

In access it will only render a check box if you also set the field to not null. If nulls are allowed, then it will display the 0 or -1 or empty.

这篇关于ADO数据库表布尔列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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