使用 ADOX 将 Table 添加到 Catalog 时报“类型无效”的原因和解决方法
http://blog.csdn.net/kfhzy/article/details/6020283
http://blog.csdn.net/kfhzy/article/details/6020545
李维的代码,原来链接的是MS SQL,改成ACCESS后,创建Table时报 类型无效 错误
原因:
除了
adDBTimeStamp 这样的Access 明显不支持的数据类型外,一般的,也有区别,adVarChar 在ACCESS里是adVarWChar
procedure TfrmCreateTable.btnCreateTableClick(Sender: TObject);
begin
// create table
with FCatalog do
begin
FTable := CoTable.Create;
FTable.ParentCatalog := FCatalog;
FTable.Name := edtTableName.Text; FTable.Columns.Append('ISBN', adVarWChar, );
FTable.Columns.Append('BookName', adVarWChar, );
FTable.Columns.Append('Publisher', adVarWChar, );
FTable.Columns.Append('Author', adVarWChar, );
// FTable.Columns.Append('PDT', adDBTimeStamp, 8); //MS SQL Server
FTable.Columns.Append('Price', adInteger, ); // create index
FIndex := CoIndex.Create;
with FIndex do
begin
Name := 'ISBN';
PrimaryKey := True;
Unique := True;
Columns.Append('ISBN', adVarWChar, );
end;
FTable.Indexes.Append(FIndex, EmptyParam);
Tables.Append(FTable);
end;
end;
使用 ADOX 创建 adDBTimeStamp 类型的字段时,会产生“类型无效”的错误提示,产生这种错误的原因是,数据库引擎 Provider 只能接受已知类型的数据类型,下面是可以接受的类型对照表:
| ADOX.DataTypeEnum 类型枚举常量 | Value | Jet 3.51 | Jet 4.0 | SQL 7.0 |
|---|---|---|---|---|
| adBinary | 128 | Yes | Yes | Yes |
| adBoolean | 11 | Yes | Yes | Yes |
| adChar | 129 | Yes | No | Yes |
| adCurrency | 6 | Yes | Yes | Yes |
| adDate | Yes | Yes | No | |
| adDouble | 5 | Yes | Yes | Yes |
| adGUID | 72 | Yes | Yes | Yes |
| adInteger | 3 | Yes | Yes | Yes |
| adLongVarBinary | 205 | Yes | Yes | Yes |
| adLongVarChar | Yes | No | Yes | |
| adLongVarWChar | 203 | No | Yes | Yes |
| adNumeric | 131 | No | Yes (with info)* | Yes (with info)* |
| adSingle | 4 | Yes | Yes | Yes |
| adSmallInt | 2 | Yes | Yes | Yes |
| adUnsignedTinyInt | 17 | Yes | Yes | Yes |
| adVarBinary | 204 | Yes | Yes | Yes |
| adVarChar | 200 | Yes | No | Yes |
| adVarWChar | 202 | No | Yes | Yes |
| adWChar | 130 | No | Yes | Yes |
| adDBTimeStamp | 135 | No | No | Yes |
ADO 数据类型
下面的表格列出了 Access、SQL Server 与 Oracle 之间的数据类型映射:
| DataType Enum | Value | Access | SQLServer | Oracle |
|---|---|---|---|---|
| adBigInt | 20 | BigInt (SQL Server 2000 +) | ||
| adBinary | 128 | Binary TimeStamp |
Raw * | |
| adBoolean | 11 | YesNo | Bit | |
| adChar | 129 | Char | Char | |
| adCurrency | 6 | Currency | Money SmallMoney |
|
| adDate | 7 | Date | DateTime | |
| adDBTimeStamp | 135 | DateTime (Access 97 (ODBC)) | DateTime SmallDateTime |
Date |
| adDecimal | 14 | Decimal * | ||
| adDouble | 5 | Double | Float | Float |
| adGUID | 72 | ReplicationID (Access 97 (OLEDB)), (Access 2000 (OLEDB)) | UniqueIdentifier (SQL Server 7.0 +) | |
| adIDispatch | 9 | |||
| adInteger | 3 | AutoNumber Integer Long |
Identity (SQL Server 6.5) Int |
Int * |
| adLongVarBinary | 205 | OLEObject | Image | Long Raw * Blob (Oracle 8.1.x) |
| adLongVarChar | 201 | Memo (Access 97) Hyperlink (Access 97) |
Text | Long * Clob (Oracle 8.1.x) |
| adLongVarWChar | 203 | Memo (Access 2000 (OLEDB)) Hyperlink (Access 2000 (OLEDB)) |
NText (SQL Server 7.0 +) | NClob (Oracle 8.1.x) |
| adNumeric | 131 | Decimal (Access 2000 (OLEDB)) | Decimal Numeric |
Decimal Integer Number SmallInt |
| adSingle | 4 | Single | Real | |
| adSmallInt | 2 | Integer | SmallInt | |
| adUnsignedTinyInt | 17 | Byte | TinyInt | |
| adVarBinary | 204 | ReplicationID (Access 97) | VarBinary | |
| adVarChar | 200 | Text (Access 97) | VarChar | VarChar |
| adVariant | 12 | Sql_Variant (SQL Server 2000 +) | VarChar2 | |
| adVarWChar | 202 | Text (Access 2000 (OLEDB)) | NVarChar (SQL Server 7.0 +) | NVarChar2 |
| adWChar | 130 | NChar (SQL Server 7.0 +) |
* 在 Oracle 8.0.x 中 - decimal 和 int 等于 number 和 number(10)。
使用 ADOX 将 Table 添加到 Catalog 时报“类型无效”的原因和解决方法的更多相关文章
- 使用IDEA在引入Schema空间时报错URI is not registered解决方法以及Idea @Autowired取消提示 方法
使用IDEA在引入Schema空间时报错URI is not registered解决方法以及Idea @Autowired取消提示 方法 Idea @Autowired取消提示 spring b ...
- Silverlight中文本框添加回车事件后,换行无法清除的解决方法
在开发Silverlight的项目中,为了更好的用户体验,我们常要给一些控件添加一些快捷键.然而,在Silverlight中当用户回车提交后,光标停留在文本框的第二行怎么也清除不掉,经过一段时间研究, ...
- MySQL出现Waiting for table metadata lock的原因以及解决方法
转自:http://ctripmysqldba.iteye.com/blog/1938150 (有修改) MySQL在进行alter table等DDL操作时,有时会出现Waiting for tab ...
- mysql 直接从date 文件夹备份表,还原数据库之后提示 table doesn`t exist的原因和解决方法
补充:正常情况下,建议数据库备份最好用工具进行备份,通过拷贝数据库表进行数据迁移,不同的环境会出现各种不同的意外问题. 背景:今天在整理一个网站的时候,操作系统由于系统自动更新导致一直出现系统蓝屏死机 ...
- 20180117MySQL出现Waiting for table metadata lock的原因以及解决方法
转自http://www.cnblogs.com/digdeep/p/4892953.html 转自:http://ctripmysqldba.iteye.com/blog/1938150 (有修改) ...
- VS2010 VC++ 项目添加引用 出现 Internal CPS Error问题原因及解决办法
在VS2010 VC++ 项目添加引用时,有时会出现Internal CPS Error错误,提示信息: 'Internal CPS Error: We couldn't find the exist ...
- MySQL出现Waiting for table metadata lock的原因以及解决方法(转)
MySQL在进行alter table等DDL操作时,有时会出现Waiting for table metadata lock的等待场景.而且,一旦alter table TableA的操作停滞在Wa ...
- 使用mvc时,在视图view中使用强类型视图,在web.config文件中添加命名空间namespace的引用不起作用,解决方法
这是view中的model代码: @model t_user_info 这是web.config配置文件只的代码: <namespaces> <add namespace=" ...
- jquery用append添加按钮之后,按钮监听无法使用的解决方法
<!DOCTYPE html><html><head><meta charset="utf-8"> <title>< ...
随机推荐
- Python3基础 if elif 示例 判断一个数在哪个区间内
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- arm linux下启动ftp服务
1.环境: /home/jello # uname -aLinux 3.10.0 #2 SMP Mon Mar 6 17:52:09 CST 2017 armv7l GNU/Linux 2.使用tc ...
- HDU 4135 Co-prime(容斥:二进制解法)题解
题意:给出[a,b]区间内与n互质的个数 思路:如果n比较小,我们可以用欧拉函数解决,但是n有1e9.要求区间内互质,我们可以先求前缀内互质个数,即[1,b]内与n互质,求互质,可以转化为求不互质,也 ...
- hdu1866 A + B forever!(面积并)题解
A + B forever! Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- LA 3135 阿格斯(优先队列)
https://vjudge.net/problem/UVALive-3135 题意: 你的任务是编写一个称为Argus的系统.该系统支持一个Register的命令 Register Q_num Pe ...
- testlogin
!/usr/bin/env python coding:utf-8 import requests import unittest import json,urllib class testlogin ...
- 机器学习-数据可视化神器matplotlib学习之路(五)
这次准备做一下pandas在画图中的应用,要做数据分析的话这个更为实用,本次要用到的数据是pthon机器学习库sklearn中一组叫iris花的数据,里面组要有4个特征,分别是萼片长度.萼片宽度.花瓣 ...
- React Native API之 ActionSheetIOS
ok!先来演示是下效果: 官网教程:http://reactnative.cn/docs/0.31/actionsheetios.html#content 上代码:引入API组件: import Re ...
- Java-Java面向对象程序设计
2017-10-09 17:23:52 在面向对象技术中,将客观世界中的一个事物作为一个对象来考虑,比如有个张先生,他就是一个对象.每个对象都有自己的属性和行为.张先生的属性根据需要有姓名.性别.身高 ...
- Python mysql-常用对象
2017-09-08 13:14:14 db = pymysql.connect(host,user,passwaord,db,chartset),charset=utf8,可以避免中文的乱码 con ...