| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1410 人关注过本帖
标题:[求助]一个网页连接两个数据库的问题?急!在线等回复
只看楼主 加入收藏
ziyan1981
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2005-11-1
收藏
 问题点数:0 回复次数:22 
[求助]一个网页连接两个数据库的问题?急!在线等回复

 楼主

<!--#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
%>
怎么改啊
搜索更多相关主题的帖子: head 数据库 网页 New 
2005-11-02 10:18
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
Set Conn=server.createobject("ADODB.CONNECTION")
Set Conn1=server.createobject("ADODB.CONNECTION")
2005-11-02 10:46
ziyan1981
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2005-11-1
收藏
得分:0 

能不能写详细点啊
怎么里面没我要的那两个数据库名称啊
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)};"

2005-11-02 10:52
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
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

2005-11-02 10:54
ziyan1981
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2005-11-1
收藏
得分:0 

现在我把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" -->

2005-11-02 11:11
ziyan1981
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2005-11-1
收藏
得分:0 

运行出现该页无法显示啊

2005-11-02 11:11
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
你看看错误信息
2005-11-02 11:15
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 

[此贴子已经被作者于2005-11-2 11:17:54编辑过]

2005-11-02 11:16
dwf99200
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-11-2
收藏
得分:0 
<%
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

[此贴子已经被作者于2005-11-2 11:21:42编辑过]

2005-11-02 11:20
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
错误信息是什么
2005-11-02 11:21
快速回复:[求助]一个网页连接两个数据库的问题?急!在线等回复
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018432 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved