教程学院
图像设计 多媒体类 机械制图 办公软件 操作系统 系统编程 网站编程 网页制作 数据库类 网络路由 网络工程 网络安全 考试认证
酷网学院
CAD
AutoCad Cam350 ProEngineer GCcam MATLAB Unigraphics SolidWorks CAXA Solid3000 Cimatron EdgeCAM
系统
安全 防火墙 病毒 WinXP Win2003 Vista
数据库
编程
网络
  网站导航: 库库中文网 · 系统编程教程 · VB程序设计 · VB函数API字符串  

一个SQL语句:alter table chat add & Text1.Text & int not null default 0

教程推荐
『一个SQL语句:alter table chat add & Text1.Text & int not null default 0』如果文章有大量图片,显示会较慢,请等待图片下载完成
 
点击数: 更新时间:2009-3-15 7:54:55 
alter table chat add " & Text1.Text & " int not null default 0
意思是添加一个字段,并设置为非空,默认值为0
但是我需要设置有效性规则,比如大于0,小于100
alter table chat add " & Text1.Text & " int not null check (>=0 and <=100) default 0  不对,该怎么改?

这个问题第1个回答:
示例

SQL code



alter table TBName add ColumnName int not null check (ColumnName >=0 and ColumnName<=100) default 0




这个问题第2个回答:
alter table TBName add ColumnName int not null check (ColumnName >=0 and ColumnName <=100) default 0
不行。。。
这个问题第3个回答:
alter table TBName add ColumnName int not null check (ColumnName >=0 and ColumnName <=100) default 0
不行。。。
这个问题第4个回答:
报什么错误?...
这个问题第5个回答:

SQL code



create table tmp1 (myid int)

alter table tmp1 add myid2 int not null check (myid2>=1 and myid2<=100) default 0




这个问题第6个回答:
create table tmp1 (myid int)
alter table tmp1 add myid2 int not null check (myid2>=1 and myid2 <=100) default 0


这个是可以的
这个问题第7个回答:
TO :vbman2003
报:字段定义语法错误。

TO:clear_zero
alter table tmp1 add myid2 int not null  default 0  这句可以,但alter table tmp1 add myid2 int not null check (myid2>=1 and myid2 <=100) default 0
不行,字段定义语法错误。。。你试过没有?

这个问题第8个回答:
给你的示例语句测试通过

如果是报语法错误。如果你语句组合变量时有问题,你可以输出语句看下

VB code



dim s as string

s="alter table chat add " & Text1.Text & " int not null check (" & Text1.Text & " >=0 and " & Text1.Text & " <=100) default 0" 

'输出检查:

debug.print s






这个问题第9个回答:
试过了,SQL server里面可以用。但是access里面用不了。。。不是变量的问题,alter table tmp1 add myid2 int not null check (myid2>=1 and myid2 <=100) default 0也不行,但alter table tmp1 add myid2 int not null  default 0  这句却可以。。疯了
这个问题第10个回答:
access的话,尝试用ADO连接,然后执行:
alter table TB add Col int not null constraint Col_Name check (Col >=0 and Col <=100) default 0

这个问题第11个回答:
谢谢,用两条语句终于搞定了。。。

】【关闭窗口
  上一页:
  下一页:
VB函数API字符串:相关文章
VB函数API字符串点击榜
普通教程VB+SQLSERCER2000+事务管理
普通教程请VB高手帮忙   把字符串赋
普通教程一个SQL语句:alter table chat
普通教程怎么样用DAO在VB2005中对MDB数据
普通教程RegOpenKeyEx老是调用不成功,返
普通教程求助vb  数组里存储字符串疑难
普通教程新手初步掌握!RadioButton中ch
普通教程怎么样将richbox1中找出指定地内
普通教程vb串口接受数据疑难
普通教程查询路径语句疑难
PHOTOSHOP - 基础教程 抠图专题 蒙版专题 3DsMax 基础 设计实例 Maya设计实例
3D设计教程
advertisement
关于站点 - 广告服务 - 联系我们 - 版权隐私 - 免责声明 - 合作伙伴 - 程序支持 - 网站地图 - 返回顶部
网站文本地图
版权所有:库库中文 2005-2007 欢迎各种媒体转载我们的原创作品[转载请注明出处]
copyright ? 2005-2008 www.QQGB.com online services. all rights reserved. 蜀ICP备05015578
Optimized for 1024x768 to Firefox,Opera and MS-IE6. Site powered by EQL. 电脑硬件 电脑知识 教程学习
红盾
热爱电脑,热爱生活
拥有电脑,拥有生命
让我们享受拥有电脑的时光