急问::ASP 连接数据库发生异常,说是数据源名称过长
如题,请各位老大给点解决方案.
login.asp源代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/ConnDB.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Request.QueryString
MM_valUsername=CStr(Request.Form("AdminName"))
If MM_valUsername <> "" Then
MM_fldUserAuthorization="AdminLevel"
MM_redirectLoginSuccess="admin.asp"
MM_redirectLoginFailed="admin.asp?login=false"
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_ConnDB_STRING
MM_rsUser.Source = "SELECT AdminName, AdminPassword"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM admin WHERE AdminName='" & Replace(MM_valUsername,"'","''") &"' AND AdminPassword='" & Replace(Request.Form("AdminPWD"),"'","''") & "'"
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
If (MM_fldUserAuthorization <> "") Then
Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization") = ""
End If
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>管理员界面</title>
<script language="JavaScript" type="text/javascript">
<!--
function PageLoad(){
<%
Select Case Request.QueryString("login")
Case "false"
Response.Write("alert(""管理员帐号或者密码错误!登录失败,请重新输入!\t"");")
Case "denied"
Response.Write("alert(""禁止匿名访问!请您输入管理员帐号和密码登录!\t"");")
End Select
%>
Login.AdminName.focus();
}
//-->
</script>
<link href="login.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#EEEEEE" onLoad="PageLoad();">
<table width="100%" height="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td><form action="<%=MM_LoginAction%>" method="POST" name="Login" id="Login">
<table border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#336699">
<tr align="center" bgcolor="#0099CC">
<td height="32" bgcolor="#466FCB" class="font14px"><strong><font color="#FFFFFF">管理员登录</font></strong></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><table width="400" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="35%" align="right">管理员帐号:</td>
<td width="65%"><input name="AdminName" type="text" class="inputbox" id="AdminName" size="32"></td>
</tr>
<tr>
<td align="right">管理员密码:</td>
<td><input name="AdminPWD" type="password" class="inputbox" id="AdminPWD" size="32"></td>
</tr>
<tr>
<td> </td>
<td align="center">
<input name="Submit" type="submit" class="button" value="登 录">
<input name="Reset" type="reset" class="button" id="Reset" value="重 置">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
conndb.asp 源代码如下
<%
' FileName="Connection_ado_conn_string.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="false"
' Catalog=""
' Schema=""
Dim MM_ConnDB_STRING
MM_ConnDB_STRING= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("database\#anpelsdb.mdb")
%>
问题点数:50、回复次数:5Top
1 楼cqluojia(人狼)回复于 2004-08-03 14:44:52 得分 0
错误信息如下:
Vbscript Runtime error 'ASP 0185 : 3219'
[Microsoft][ODBC 驱动程序管理器] 数据源名称过长
/login.asp,line 14
Top
2 楼yufeiyxl(与飞)回复于 2004-08-03 15:00:43 得分 50
现在访问数据库不需要专门建立数据源
给你一个常用的简单链接
<%
Dim rs,conn,strsql,database,dbpath
database=1 '设置使用的数据库类型,1=SQL SERVER,其他为ACCESS
If database=1 then
strsql="driver={SQL Server};server=localhost;uid=sa;pwd=;database=fdc"
Else
dbpath=server.mappath("fdc.asa")
strsql="DBQ="+dbpath+";DRIVER={Microsoft Access Driver (*.mdb)};"
End if
Set conn=server.createobject("adodb.connection")
conn.open strsql
%>Top
3 楼yizia(椅子)回复于 2004-08-03 15:05:32 得分 0
在MM_rsUser.Open之前一行,把source输出,放到数据库里去调试一下Top
4 楼seesea125(执著)回复于 2004-08-03 15:08:24 得分 0
建立数据源
太古老,支持yufeiyxl(与飞) (Top
5 楼cqluojia(人狼)回复于 2004-08-03 15:52:11 得分 0
不懂哦,大哥,可以说详细点吗??Top




