一个页面内多个数据库操作,请帮帮忙!

shortppsy 2005-08-23 04:46:06
我的本意是,检测到sn和password的值与数据库内的值相同时,并且sn和password的位数等于8位时
进行另外一个数据库的操作(2个不同的数据库)。也就是在
if password=rs("pwd") and sn=rs("sn") and a=8 and b=8 then
之后的那一段
但是不知道怎么在一个页面内完成多个数据库的操作,请大家帮帮忙好吗?

<%
dim sql
dim rs
dim sn
dim password
dim access


sn=trim(request.Form("txtsn"))
password=(trim(Request.Form("txtpwd")))

%>

<!--#include file="conn1.asp"-->
<%

a=(len(password))
b=(len(sn))
sql="select * from main "
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
if password=rs("pwd") and sn=rs("sn") and a=8 and b=8 then
.........''另一个数据库的操作
response.write("OK")
else
call Error
end if
else
call Error()
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
%>

<%sub Error() %>
<script language="JavaScript">
alert(' error')
window.history.go(-1);
</script>
<%end sub%>
...全文
79 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
huo789 2005-08-23
  • 打赏
  • 举报
回复
呵呵,
1、如果是同一个数据库里面的两张表的话,不用建立新的connection,只要建新的RECORDSET对象即可,或者关闭当前RECORDSET对象,然后再让他指向新的SQL
2、如果是 两个不同的数据库的话,就应该建立新的connection,RECORDSET对象
shine2000 2005-08-23
  • 打赏
  • 举报
回复
<!--#include file="conn1.asp"-->
<%

a=(len(password))
b=(len(sn))
sql="select * from main "
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
if password=rs("pwd") and sn=rs("sn") and a=8 and b=8 then
<!--#include file="conn1.asp"-->
<%

a=(len(password))
b=(len(sn))
sql="select * from main "
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
if password=rs("pwd") and sn=rs("sn") and a=8 and b=8 then
rs.Close
  Set rs=Nothing
  ObjConn.Close
  Set objConn=Nothing
----建立新連接
Set objConn=Server.CreateObject("ADODB.Connection")
objConn.ConnectionString=......
objConn.Open
Set rs=Server.CreateObject("ADODB.Recordset")
..............................
hety521 2005-08-23
  • 打赏
  • 举报
回复
先重新建立数据库连接对象啊。和你开始写的连接代码一样,不过注意定义的变量别重复了就行。然后建立新的recordset 对象进行你需要的操作。还不懂的话继续回复!我再给你详细代码说明。我想你应该明白了
jingxiaoping 2005-08-23
  • 打赏
  • 举报
回复
顶楼上的,在那里直接建立新的RECORDSET对象即可。
set temp=server.createobject("adodb.recordset")
sql="###"
temp.open sql,conn,1,3
'进行操作之类的。
temp.close
set temp=nothing
HHH3000 2005-08-23
  • 打赏
  • 举报
回复
另一个数据库?

那就重写连接字符串,建立新的connection对象贝~~

28,391

社区成员

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

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