如何用数据记录中的值给变量付值?

yuanl 2005-04-13 02:52:44
我先打开一个数据表table1,
然后,根据table1中的某一字段的值,来查询第二个表。
cTSql = "select * from table where ID="&cPcode
Set Rst = Server.CreateObject("ADODB.RecordSet")
Rst.CursorType = 3
Rst.Open cTSql, mydb
If Rst.Eof Then Response.Write "无目录"
cCODE=Rst("CODE")

cSql = "select * from table2 where tcode='"&cCODE&"' order by SEND_TIME DESC"
Set Rs = Server.CreateObject("ADODB.RecordSet")
Rs.CursorType = 3
Rs.Open cTSql, mydb
这样,测试时,提示错误
...全文
89 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
enjsky 2005-04-13
  • 打赏
  • 举报
回复
1、Rst.CursorType = 3 这个没用,去掉
2、tcode='"&cCODE"'应为:tcode='"&cCODE&"'

iexapl 2005-04-13
  • 打赏
  • 举报
回复
tcode='"&cCODE"'应为:tcode='"&cCODE&"'
yuanl 2005-04-13
  • 打赏
  • 举报
回复
Microsoft VBScript 编译器错误 错误 '800a0401'

语句未结束

latelist.asp,行55

cSql = "select * from table2 where tcode='"&cCODE"' order by SEND_TIME DESC"
-----------------------------------------------------------^
提示的错误
iexapl 2005-04-13
  • 打赏
  • 举报
回复
cTSql = "select * from table where ID="&cPcode
Set Rst = Server.CreateObject("ADODB.RecordSet")
Rst.Open cTSql,mydb,1,1
If Rst.Eof Then
Response.Write "无目录"
Else
cCODE=Rst("CODE")
End If
Rst.Close
If cCODE<>"" Then
Set Rs = Server.CreateObject("ADODB.RecordSet")
cSql = "select * from table2 where tcode='"&cCODE&"' order by SEND_TIME DESC"
Rs.Open cTSql, mydb,1,1
End If
iexapl 2005-04-13
  • 打赏
  • 举报
回复
Rst.CursorType = 3什么意思?
我不知道这个
baikaishui_0825 2005-04-13
  • 打赏
  • 举报
回复
try it:
cTSql = "select * from table where ID="&cPcode
Set Rst = Server.CreateObject("ADODB.RecordSet")
Rst.Open cTSql,mydb,1,1
If Rst.Eof Then
Response.Write "无目录"
Else
cCODE=Rst("CODE")
End If
Rst.Close
If cCODE<>"" Then
cSql = "select * from table2 where tcode='"&cCODE&"' order by SEND_TIME DESC"
Rs.Open cTSql, mydb,1,1
End If

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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