dll的简单问题,我在asp页面中定义了conn,在dll中怎么调用

ww_cain 2006-03-11 09:52:17
dll的简单问题,我在asp页面中定义了conn,在dll中怎么调用conn对象
...全文
216 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
tangxufeng 2006-04-21
  • 打赏
  • 举报
回复
把conn作为参数传进去,比较
function tests(conn)
...
end function
wwsh 2006-04-20
  • 打赏
  • 举报
回复
ww_cain 2006-04-20
  • 打赏
  • 举报
回复
ddddddddddd dddddddddddddddddddddddddddd
jacky227 2006-04-19
  • 打赏
  • 举报
回复
也想知道
ww_cain 2006-04-13
  • 打赏
  • 举报
回复
ding
wwsh 2006-04-07
  • 打赏
  • 举报
回复
路过,是不是也是在dll里有一个close方法,关闭时和connection一样,调用它的close方法,然后就set 我的组件=nothing。
ww_cain 2006-03-27
  • 打赏
  • 举报
回复
顺便在问一个问题,在应用组件之后,在那里关闭recordset和connection对象,在dll里,还是asp里,或是直接set xxx=nothing(xxx为我们自己的dll组件)?????
ww_cain 2006-03-13
  • 打赏
  • 举报
回复
顺便在问一个问题,在应用组件之后,在那里关闭recordset和connection对象,在dll里,还是asp里,或是直接set xxx=nothing(xxx为我们自己的dll组件)?????
ww_cain 2006-03-12
  • 打赏
  • 举报
回复
明天再试了
ww_cain 2006-03-12
  • 打赏
  • 举报
回复
嗯,应该是
emhuangzi 2006-03-12
  • 打赏
  • 举报
回复
调用里面的连接字符串撒
ww_cain 2006-03-12
  • 打赏
  • 举报
回复
我分析了一下,动易应该是用 Application("ConnStr") = ConnStr,然后在dll里用conn打开的
ww_cain 2006-03-12
  • 打赏
  • 举报
回复
to caixinke(新一)
我试了,不行的,下面是我的dll源码:
Option Explicit

Private Context As ScriptingContext
Private Application As Application
Private Request As Request
Private Response As Response
Private Server As Server
Private Session As Session
Private rs As ADODB.Recordset
Private conn As ADODB.Connection

Public Sub OnStartPage(PassedScriptingContext As ScriptingContext)
Set Context = PassedScriptingContext
Set Application = Context.Application
Set Request = Context.Request
Set Response = Context.Response
Set Server = Context.Server
Set Session = Context.Session
End Sub
'返回所有的雇员列表

Public Function GetEmployeeList() As ADODB.Recordset
Dim strSql As String
Set rs = New ADODB.Recordset
strSql = "select * from [user]"
rs.CursorLocation = adUseClient
rs.Open strSql, conn, adOpenStatic
Set GetEmployeeList = rs
End Function

Public Sub OnEndPage()
Set Context = Nothing
Set Application = Nothing
Set Request = Nothing
Set Response = Nothing
Set Server = Nothing
Set Session = Nothing
End Sub

conn.asp源码:
<%
dim SqlUsername,SqlPassword,SqlDatabaseNam,SqlHostIP,ConnStr
'如果是SQL数据库,请认真修改好以下数据库选项
SqlUsername = "sa" 'SQL数据库用户名
SqlPassword = "sa" 'SQL数据库用户密码
SqlDatabaseName = "blogzt" 'SQL数据库名
SqlHostIP = "127.0.0.1" 'SQL主机IP地址(本地可用“127.0.0.1”或“(local)”,非本机请用真实IP)
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlHostIP & ";"
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
Err.Clear
Set conn = Nothing
Response.Write "数据库连接出错,请检查Conn.asp文件中的数据库参数设置。"
Response.End
End If
%>
调用页源码:
<!--#include file="conn.asp"-->
<%
Dim DataQuery,rs
Set DataQuery=Server.CreateObject("bi.xxx")
Set Rs=DataQuery.GetEmployeeList()
if rs.eof then
Response.write "没有数据,请查询"
Response.end
end if
while not rs.eof
response.Write(rs("username")&"<br>")
rs.movenext
wend
%>
结果是:
ADODB.Recordset 错误 '800a0e7d'

连接无法用于执行此操作。在此上下文中它可能已被关闭或无效。

/3.asp,行5
caixinke 2006-03-11
  • 打赏
  • 举报
回复
在asp页面中定义和在dll中用的名字相同的conn就可以了
ww_cain 2006-03-11
  • 打赏
  • 举报
回复
我是看不懂动易的调用方式而已
他在dll之外定义连接,又不见他传conn对象,他在dll里如何引用
mrwang2000 2006-03-11
  • 打赏
  • 举报
回复
个人意见 仅供参考

如果你的dll是用VB开发的,则在你的工程中引用两个组件
名字记不太清楚了
一个是asp的什么library组件
另一个是ado什么2.6
然后就可以用ADODB的对象了,你可以编写一个函数或子过程,里面的参数用byref引用就可以

另:为什么要在dll之外定义conn呢?为什么不把数据库链接对象封装在dll之内呢?

28,390

社区成员

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

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