新微赢技术网

标题: [求助]一个网页连接两个数据库的问题?急!在线等回复 [打印本页]

作者: 神①→沙加    时间: 2010-1-13 07:29
标题: [求助]一个网页连接两个数据库的问题?急!在线等回复
 楼主
<!--#include file="New/Function.asp"-->
<!--#include file="New/Conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%= SelectDBName("WebTitle","SystemSet","[id]",1) %></title>
<link href="New/Css.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0" topmargin="0">
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2"><!--#include file="New/Top.asp" --></td>
</tr>
<tr>
<td width="220" valign="top"><!--#include file="New/Left.asp" --></td>
<td width="540" valign="top" bgcolor="#FFFFFF" class="Td-1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%Set Rs=Conn.Execute("Select * from [reColumn] Where id="&Trim(Request.QueryString("id")))%>
<tr>
<td height="30" align="center" background="New/Img/columnTitle.gif"><strong><font color="#FFFFFF">
<%=Rs("Title")%></font></strong></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="15">
<tr>
<td><%=Rs("Message")%></td>
</tr>
</table></td>
</tr>
<%Set Rs=Nothing%>
<tr>
<td align="center">
<table width="90%" border="0" cellspacing="0" cellpadding="3">
<%
Set Rs=Conn.Execute("Select * From reColumn Where fID="&Trim(Request.QueryString("id")))
Do While Not Rs.Eof
Set Rs1=Conn.Execute("Select * From reProgram Where cID="&Rs("ID"))
Do While Not Rs1.Eof
%>
<tr>
<td>[<%=Rs("Title")%>]<a href="New/reProgram.asp?id=<%=Rs1("ID")%>"><%=Rs1("Title")%></a></td>
</tr>
<%
Rs1.moveNext
Loop
Set Rs1=Nothing
Rs.moveNext
Loop
Set Rs=Nothing
%>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"><!--#include file="New/Bottom.asp"--></td>
</tr>
</table>
</body>
</html>
以上是我的原程序
运行也没错误
现在我要把<!--#include file="New/Top.asp" -->
改为<!--#include file="include/Top.asp" -->
而inculde/top.asp是调用的data下的数据库
连接这个数据库的inculde/conn.asp
<%
dim stime,typess
stime=timer()
typess=1
dim conn
dim connst
on error resume next
connst="DBQ="+server.mappath("data/!#%&@$^.asp")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connst

if session("cffilmuser")="" then
if Request.cookies("gl")("cffilmuser")<>"" then
cffilmuser=Request.cookies("gl")("cffilmuser")
session("cffilmuser")=cffilmuser
end if
if Request.cookies("gl")("cffilmusergrade")<>"" then
cffilmusergrade=Request.cookies("gl")("cffilmusergrade")
session("cffilmusergrade")=cffilmusergrade
end if
name=session("cffilmuser")
else
name=session("cffilmuser")
end if

if session("cffilmadmin")="" then
if Request.cookies("cffilmadmin")<>"" then
cffilmadmin=Request.cookies("cffilmadmin")
session("cffilmadmin")=cffilmadmin
end if
end if

webtitle="东山广播电视网"
%>
而原来那个连接的数据库是远程的
连接数据库的new/conn.asp是
<%
Response.Buffer=True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
'on error resume next

dataBaseType=2'数据库类型:1为Acc,2为Sql
Dim ConnStr
If dataBaseType = 2 Then
Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName
SqlDatabaseName = "dstvdata"
SqlPassword = "11111111"
SqlUsername = "dstvdata"
SqlLocalName = "202.109.237.42"
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Else
Connstr="DBQ="+server.mappath("./MyDataBase/#My#Data#Base#.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
End IF
Set Conn=server.createobject("ADODB.CONNECTION")
Conn.open ConnStr
Response.Write SqlLocalName
%>
怎么改啊
作者: 孤独的囚鸟    时间: 2010-1-13 07:29
Set Conn=server.createobject("ADODB.CONNECTION")
Set Conn1=server.createobject("ADODB.CONNECTION")
作者: 梦aiq逍遥    时间: 2010-1-13 07:29
能不能写详细点啊
怎么里面没我要的那两个数据库名称啊
connst="DBQ="+server.mappath("data/!#%&@$^.asp")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Connstr="DBQ="+server.mappath("./MyDataBase/#My#Data#Base#.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
作者: 爱(じΩvê)    时间: 2010-1-13 07:29
Set Conn=server.createobject("ADODB.CONNECTION")
Set Conn1=server.createobject("ADODB.CONNECTION")

Connst="DBQ="+server.mappath("data/!#%&@$^.asp")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Conn.open ConnStr

Connstr="DBQ="+server.mappath("./MyDataBase/#My#Data#Base#.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Conn1.open ConnStr
作者: 简单快乐    时间: 2010-1-13 07:29
现在我把include/conn.asp写成
<%
dim stime,typess
stime=timer()
typess=1
dim conn
dim connst
on error resume next
connstr="DBQ="+server.mappath("data/!#%&@$^.asp")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
connstr="DBQ="+server.mappath("./MyDataBase/#My#Data#Base#.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn1=server.createobject("ADODB.CONNECTION")
conn1.open connstr

if session("cffilmuser")="" then
if Request.cookies("gl")("cffilmuser")<>"" then
cffilmuser=Request.cookies("gl")("cffilmuser")
session("cffilmuser")=cffilmuser
end if
if Request.cookies("gl")("cffilmusergrade")<>"" then
cffilmusergrade=Request.cookies("gl")("cffilmusergrade")
session("cffilmusergrade")=cffilmusergrade
end if
name=session("cffilmuser")
else
name=session("cffilmuser")
end if
if session("cffilmadmin")="" then
if Request.cookies("cffilmadmin")<>"" then
cffilmadmin=Request.cookies("cffilmadmin")
session("cffilmadmin")=cffilmadmin
end if
end if
webtitle="东山广播电视网"
%>
就是把connstr="DBQ="+server.mappath("./MyDataBase/#My#Data#Base#.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn1=server.createobject("ADODB.CONNECTION")
conn1.open connstr
加进去了
然后把<!--#include file="New/Top.asp" -->改为
<!--#include file="include/Top.asp" -->
作者: 成熟之惑    时间: 2010-1-13 07:30
运行出现该页无法显示啊
作者: 林枫    时间: 2010-1-13 07:30
你看看错误信息
作者: 爱随缘    时间: 2010-1-13 07:30

作者: 一网情深    时间: 2010-1-13 07:30
<%
dim stime,typess
stime=timer()
typess=1
dim conn ,conn1
dim connst,connstr
on error resume next
connst="DBQ="+server.mappath("data/!#%&@$^.asp")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connst
connstr="DBQ="+server.mappath("./MyDataBase/#My#Data#Base#.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn1=server.createobject("ADODB.CONNECTION")
conn1.open connstr
作者: 亾莣乁靈柩    时间: 2010-1-13 07:30
错误信息是什么




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2