读书人

ACCESS中SQL语句有关问题

发布时间: 2012-01-29 21:39:32 作者: rapoo

ACCESS中SQL语句问题
strsql = "select * from Msysobjects where name= 'cs_temp ' "
If runsql(strsql) = True Then
If rct.EOF Then '这里是这样判断数据库中是否有这个表吗??如果不是该怎么样判断这个表的存在~~~~
strsql = "select a.cname,a.cbir,a.cwork,a.cdan,b.cdtime,b.cctel,b.cliwu into cs_temp c from cs_info a right join cs_ding b on b.ctel=a.ctel where a.cname= ' " & Trim(Text1.Text) & " ' and b.cdtime= ' " & DTPicker1.Value & " ' " 这句话为什么运行保存 那里错了~ 语法有问题????
runsql (strsql)

Else
strsql = "drop table cs_temp "
runsql (strsql)
MsgBox 2
strsql = "select a.cname,a.cbir,a.cwork,a.cdan,b.cdtime,b.cctel,b.cliwu into cs_temp c from cs_info a right join cs_ding b on b.ctel=a.ctel where a.cname= ' " & Trim(Text1.Text) & " ' and b.cdtime= ' " & DTPicker1.Value & " ' "
runsql (strsql)
MsgBox 3
strsql = "delete cs_info from cs_temp a where a.cname=cs_info.cname "
If runsql(strsql) = True Then
MsgBox a
End If
End If


End If

[解决办法]
strsql = "select * from Msysobjects where name= 'cs_temp ' "
If runsql(strsql) = True Then
If rct.EOF Then '这里是这样判断数据库中是否有这个表吗??如果不是该怎么样判断这个表的存在~~~~

strsql = "create table cs_temp (cname varchar(10),
cbir varchar(10),...) "
runsql (strsql)


strsql = "insert into cs_temp select a.cname,a.cbir,a.cwork,a.cdan,b.cdtime,b.cctel,b.cliwu from cs_info a right join cs_ding b on b.ctel=a.ctel where a.cname= ' " & Trim(Text1.Text) & " ' and b.cdtime= ' " & DTPicker1.Value & " ' "
runsql (strsql)

Else
strsql = "drop table cs_temp "
runsql (strsql)
MsgBox 2
strsql = "select a.cname,a.cbir,a.cwork,a.cdan,b.cdtime,b.cctel,b.cliwu into cs_temp c from cs_info a right join cs_ding b on b.ctel=a.ctel where a.cname= ' " & Trim(Text1.Text) & " ' and b.cdtime= ' " & DTPicker1.Value & " ' "
runsql (strsql)
MsgBox 3
strsql = "delete cs_info from cs_temp a where a.cname=cs_info.cname "
If runsql(strsql) = True Then
MsgBox a
End If
End If
End If

读书人网 >SQL Server

热点推荐