有关使用临时表的问题

byj2001329 2003-10-21 11:08:34
程序如下:
Option Explicit
Dim cc As New ADODB.Connection
Dim rst As New ADODB.Recordset

Private Sub Command1_Click()
cc.Execute "select top 1 * into #lls from jc_bmxx"
MsgBox 1
cc.Execute "select * from #lls"
MsgBox 2
cc.Execute "select * from #lls"
MsgBox 3
Set rst = cc.Execute("select * from #lls") '如果去掉这句,下句不会出错!!
MsgBox 4
cc.Execute "drop table #lls" ' ??这句话会出错,提示说“#lls 在系统目录中不存在
MsgBox 5
End Sub

Private Sub Form_Load()
cc.ConnectionString = "....................."
cc.Open
End Sub


为什么?请指教
...全文
123 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
byj2001329 2003-10-22
  • 打赏
  • 举报
回复
up
zqfleaf 2003-10-21
  • 打赏
  • 举报
回复
临时表是创建在TEMPDB数据库中的,当前链接断开后会自动删除。
如果你要强行的话可以试试
cn.execute "use tempdb"
cn.execute "drop talbe #temp"
cn.execute "user 当前数据库名"
byj2001329 2003-10-21
  • 打赏
  • 举报
回复
数据库语句在查询分析器中运行无误,应该没错
wang7655 2003-10-21
  • 打赏
  • 举报
回复
看看你的数据库语句啊!

是什么错误应该好找啊!
byj2001329 2003-10-21
  • 打赏
  • 举报
回复
如果去掉出错的那句,把第一句改成cc.Execute "if object_id('tempdb.dbo.#lls') is not null drop table #lls select top 1 * into #lls from jc_bmxx" 则没有问题
这到底是为什么?

byj2001329 2003-10-21
  • 打赏
  • 举报
回复
可是如果不附值给记录集,是不会出现问题的。

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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