请教在VB编写的程序运行过程中如何操作SQL的问题?

Hoee_cn 2003-06-12 07:31:15
后学目前遇到以下一个问题,请各位朋友帮助?
1、在程序运行过程中在一个数据库里新创建1个表?
2、如何在程序运行中检查数据库中以某名字命名的数据表是否存在?
由于时间关系暂时不能去书店,所以在这里请教有经验的高手,环境是VB+SQL7.0,以上2个问题如何编写代码?请赐教。谢谢!
...全文
49 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dafu71 2003-06-12
  • 打赏
  • 举报
回复
1
adocnCase为你的ADOCONNECTION连接
Ssql="Create Table Users(ID int IDEntity(1,1) not Null Primary Key,UserName Varchar(20) not Null,Pwd Varchar(20) Null,Purview TinyInt default 0)"
or
Ssql="select * into newtable from oldtable where 1=2"
adocnCase.Execute(ssql)
2
Ssql="Select 1 from sysobjects Where Name='yourtable' and xtype='u'"
rst.open sql
if rst.eof then
msgbox "不在"
else
msgbox "在"
end if

fling_boy 2003-06-12
  • 打赏
  • 举报
回复
大家都说了
pengdali 2003-06-12
  • 打赏
  • 举报
回复
1、在程序运行过程中在一个数据库里新创建1个表?
create table 表名(a int,b int)

select * into 新表 from 旧表

2、如何在程序运行中检查数据库中以某名字命名的数据表是否存在?
if objects_id('你的表名') is not null
select '在'
else
select '不在'
huayuxing 2003-06-12
  • 打赏
  • 举报
回复
1
adocnCase为你的ADOCONNECTION连接
Ssql="Create Table Users(ID int IDEntity(1,1) not Null Primary Key,UserName Varchar(20) not Null,Pwd Varchar(20) Null,Purview TinyInt default 0)"
adocnCase.Execute(ssql)
2
Ssql="Select * from SysDataBases Where Name='Cases'"

wynbfqny 2003-06-12
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/1876/1876180.xml?temp=.2484705

别浪费分了

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧