ASP 连接数据库问题,急救
<%
Dim conn
Dim db
Dim strConn
db = Server.MapPath("/mail")
db = Mid(db, 1, InStrRev(db, "\")) & "db\db.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
strConn = "DSN=CMailServer"
conn.open strConn
public function getUserAmount
dim strAccount
If InstrRev(Session("Account"), "@") > 0 Then
strAccount = Mid(Session("Account"), 1, Len(Session("Account")) - Len(Session("Domain")) - 1)
Else
strAccount = Session("Account")
End If
Dim cn,rs,strAmount
Set cn=Server.CreateObject("AdoDB.Connection")
cn.Open IDS_WEBFAX_CONNSTR,IDS_WEBFAX_DBUSER,IDS_WEBFAX_DBPASSWD
set rs=Server.CreateObject("AdoDB.RecordSet")
rs.Open "select isnull(str(amount),'--') as amount from userInfo where username = '" + strAccount +"'",cn
if not rs.EOF then
strAmount = rs("amount")
else
strAmount = "--"
end if
rs.Close
cn.Close
getUserAmount = strAmount
end function
%>
主要不错出现在cn.Open IDS_WEBFAX_CONNSTR,IDS_WEBFAX_DBUSER,IDS_WEBFAX_DBPASSWD这句上面
它对应的dns文件是:
[ODBC]
DRIVER=SQL Server
UID=sa
DATABASE=webfax
WSID=(local)
APP=Microsoft Open Database Connectivity
SERVER=(local)
每次连接出现错误提示是:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
常见错误: 无效的文件 dsn ''
/WebFax/conn.asp, 第 30 行