我在RDS中用同一个connection建立两个recordset的问题

jzywh 2003-09-01 08:24:03
第一个recordset(res)调用成功,第二个(rec)却不行

程序中有2个 rdoRecordset 分别为 res 和 rec

res调用成功 rec却不能成功调用

只要有rec的语句编译时都提示 type dismatch(类型不匹陪)

不止是何原应,请高手相助,我是初学者,以前做 ASP

代码如下:

Public con As rdoConnection, res As rdoResultset, rec As rdoResultsets

Function output(strSQLServerName, strSQLDBName, strSQLDBUserName, strSQLDBPassword)

Dim strParent As String
strParent = Dir1.Path & "classic"

Set fs = CreateObject("Scripting.FileSystemObject")

If Not fs.FolderExists(strParent) Then
fs.CreateFolder (strParent)
End If

With rdoEngine
.rdoDefaultUser = strSQLDBUserName
.rdoDefaultPassword = strSQLDBPassword
.rdoDefaultCursorDriver = rdUseServer
.rdoDefaultLoginTimeout = 15
End With

Set con = rdoEnvironments(0).OpenConnection("", rdDriverNoPrompt, False, "driver={SQL Server};server=" & strSQLServerName & "; database=" & strSQLDBName)

Set res = con.OpenResultset("select Title,Boardid,id,PostUserName,dateandtime,Announceid from BestTopic")

Do Until res.EOF Or res.BOF

Set rec = con.OpenResultset("select ParentID,Announceid,Body,UserName from bbs1 order by Announceid asc")

If Not fs.FolderExists(strParent & "\" & Trim(res("Boardid"))) Then
fs.CreateFolder (strParent & "\" & Trim(res("Boardid")))
End If

Set XmlFile = fs.CreateTextFile(strParent & "\" & Trim(res("Boardid")) & "\" & Trim(res("title")) & ".xml")
XmlFile.writeline ("<?xml version='1.0' encoding='GB2312'?>")
XmlFile.writeline ("<?xml:stylesheet type='text/xsl' href='../csdn.xsl'?>")
XmlFile.writeline ("<Topic>")
XmlFile.writeline ("<Issue>")
XmlFile.writeline ("<PostUserNickName>" & res("PostUserName") & "</PostUserNickName>")
XmlFile.writeline ("<TopicName>" & res("title") & "</TopicName>")
XmlFile.writeline ("<RoomName>" & res("Boardid") & "</RoomName>")
XmlFile.writeline ("<PostDateTime>" & res("dateandtime") & "</PostDateTime>")
XmlFile.writeline ("<Content></Content>")
XmlFile.writeline ("</Issue>")
XmlFile.writeline ("<Replys>")
rec.MoveNext
Do Until rec.EOF Or rec.BOF
XmlFile.writeline ("<Reply>")
XmlFile.writeline ("<PostUserNickName>" & rec("UserName") & "</PostUserNickName>")
XmlFile.writeline ("<Content>" & rec("Body") & "</Content>")
XmlFile.writeline ("<PostDateTime>" & rec("DateAndTime") & "</PostDateTime>")
XmlFile.writeline ("</Reply>")
rs.MoveNext
Loop
XmlFile.writeline ("</Replys>")
XmlFile.writeline ("</Topic>")
rs.Close
Set rs = Nothing
XmlFile.Close
Set XmlFile = Nothing
res.MoveNext
Loop

res.Close
Set res = Nothing
con.Close
Set con = Nothing

MsgBox "精华帖已成功导出到" & strParent & "\下!"

End Function

...全文
36 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
tanqi 2003-09-14
  • 打赏
  • 举报
回复
但如果不是sql,而是access,用iis为db建立虚拟目录,在客户端用ado如何访问呢?请帮忙。
tanqi 2003-09-14
  • 打赏
  • 举报
回复
但如果不是sql,而是access,用iis为db建立虚拟目录,用ado如何访问呢?请帮忙。
firechun 2003-09-02
  • 打赏
  • 举报
回复
dim conn as new adodb.connection
dim rs as new adodb.recordset

conn.open "Provider=SQLOLEDB.1;" _
& "Password=密码;" _
& "Persist Security Info=True;" _
& "User ID=数据库用户名;" _
& "Initial Catalog=数据库名;" _
& "Data Source=服务器名"
rs.open sql语句,conn,adOpenKeyset, adLockReadOnly
看看MSDN吧
jzywh 2003-09-02
  • 打赏
  • 举报
回复
ADO能连远程数据库吗??

给个sample呀..
firechun 2003-09-02
  • 打赏
  • 举报
回复
代码好长,没看

为什么用RDO不用ADO?
jzywh 2003-09-02
  • 打赏
  • 举报
回复
怎么没人知道嘛!
planetike 2003-09-01
  • 打赏
  • 举报
回复
帮你顶.

1,216

社区成员

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

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