您好我试图连接到oracle数据源,看起来当我测试代码时它给了我一个错误。另外,我相信它可能是我的数据源路径是错误的。有没有办法以oracle或任何方式检查数据源路径?感谢
<!--INCLUDED FILE = reset_password.asp -->
<%
DIM strEmail
strEmail = Request.Form("email")
IF strEmail <> "" THEN
%>
<!--#INCLUDE VIRTUAL="/includes/connection.asp"-->
<!-- ************SQL CONNECTION INSERT HERE*********************-->
<!-- *******
Set objDB = Server.CreateObject("ADODB.Connection")
objDB.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=c:\mydatabase.mdb"
**** -->
conn.
<%
DIM objDB
objDB = "SELECT email_addr,medacist_password FROM medacist_user WHERE email_addr = '" & strEmail & "'"
Set objDB = Server.CreateObject("ADODB.Connection")
objDB.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE= mmsg; Persist Security Info=True; User ID=mmsg; Password=langa;"
IF objDB.EOF THEN
Response.Write "That email address was not found in our database. Please click Back on your browser and enter the email address you registered with."
ELSE
DIM strPassword
strPassword = objDB("medacist_password")
DIM mail, objMail
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = "example@yahoo.com"
objMail.Subject = "Your Password"
objMail.To = strEmail
objMail.Body = "Here is your login password: " & strEmail
objMail.Send
'Set objMail to nothing to destory the mail object'
Set objMail = nothing
Response.Write "Your password has been sent to your email address."
END IF
ELSE
Response.Write "Please click Back on your browser and enter the email address you registered with."
END IF
&#13;
答案 0 :(得分:1)
MICROSOFT.JET.OLEDB.4.0是MS Access的OLEDB提供程序。您需要Oracle的ODBC或OLEDB连接字符串。有关选项
,请参阅此页面http://www.connectionstrings.com/oracle/
之后你需要一个记录集对象,如上面kloarubeek建议的那样。一个非常简单的方法是:
DIM objDB, rs, rssql
Set objDB = Server.CreateObject("ADODB.Connection")
objDB.Open "[your connection string goes here]"
rssql = "SELECT email_addr,medacist_password FROM medacist_user WHERE email_addr = '" & strEmail & "'"
Set rs = objDB.Execute(rsSQL)
此外,我注意到您正在使用CDONTS发送电子邮件。它已被弃用,默认情况下,您无法在当前版本的IIS上找到它。再看看CDOSYS
http://www.w3schools.com/asp/asp_send_email.asp
最后,我向所有学习经典ASP的人推荐这个页面。它解释了如何获取比基本的500内部服务器错误页面更有用的错误消息。
http://www.chestysoft.com/asp-error-messages.asp
修改
使用CDOSYS和记录集的密码检索脚本示例。
NB CDO配置取决于您的smtp服务器。应用程序(&#34; conn&#34;)表示我的实际连接字符串位于名为global.asa的文件中。该页面实际上连接到SQL Server数据库,但代码应该与Oracle一起使用
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
If InStr(request.form("username"),"@") > 0 Then
Set objMail = Server.CreateObject("CDO.Message")
Set iConfg = Server.CreateObject("CDO.Configuration")
Set Flds = iConfg.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youremailusername"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "youremailpasword"
.Update
End With
objMail.Configuration = iConfg
objMail.To = CStr(request.form("username"))
objMail.From = "you@yourdomain.com"
objMail.Subject = "Your login details"
objMail.TextBody = "Your login details are as follows " & vbcrlf & vbcrlf
set conn = Server.CreateObject("ADODB.Connection")
conn.open Application("conn")
sql = "select ContactEmailAddress, ContactAffiliateUsername, ContactAffiliatePassword from Contacts where ContactEmailAddress ='" & request.form("username") & "'"
set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,3,1
If rs.bof And rs.eof Then
response.redirect("invalidemailpage.asp?invalidemail=2")
Else
objMail.To = RS("ContactEmailAddress")
objMail.TextBody = objMail.TextBody & "Username = " & RS("ContactAffiliateUsername") & ", Password = " & RS("ContactAffiliatePassword") & vbcrlf
End If
objMail.Send
Set objMail = Nothing
rs.close
set rs = nothing
conn.close
set conn = nothing
response.redirect("login.asp?sentpassword=1")
Else
response.redirect("invalidemailpage.asp?invalidemail=1")
End If
%>
答案 1 :(得分:0)
我更新代码并尝试工作。并且似乎结果仍然是相同的错误500.我还添加了另一个asp文件,用户输入电子邮件并单击重置按钮直接确认.asp。我的代码出了什么问题。
<html>
<head>
<title> Reset Password</title>
</head>
<body>
<STYLE type="text/css">
BODY {
background: #B4D7EB url("https://www.medacist.com/images/pic_medacist_gradient.jpg");
background-attachment: fixed;
background-repeat: repeat-x;
background-attachment: scroll;
}
</STYLE>
<div align="center">
<table border="0" width="100" id="table1" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<table border="0" width="100%" id="table2" cellspacing="0" cellpadding="0">
<tr><td valign="top"><img border="0" src="https://www.medacist.com/images/pic_medacist_header.jpg"></td></tr>
<tr><td valign="top">
<table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" bgcolor="#BBD6E7"><a href="http://www.medacist.com/index.asp"><img border="0" src="https://www.medacist.com/images/pic_medacist_head_01.jpg"></a></td>
<td valign="top" bgcolor="#BBD6E7"><img border="0" src="https://www.medacist.com/images/pic_medacist_nav_08.jpg"></td>
</tr>
</table>
</td></tr>
<tr><td valign="top"><img border="0" src="https://www.medacist.com/images/pic_medacist_hrule_01.jpg"></td></tr>
<tr><td valign="top" bgcolor="#FFFFFF">
<table border="0" width="100%" id="table4" cellspacing="0" cellpadding="0">
<tr><td valign="top">
<table border="0" width="100%" id="table6" cellspacing="0" cellpadding="0">
<tr><td valign="top"><img border="0" src="https://www.medacist.com/images/pic_medacist_main_slogan.jpg"></td></tr>
<tr><td valign="top" >
<center>
<table class="table1" width="100%" id="table8" cellspacing="0" cellpadding="0">
</table>
<h1>Forgot Your Password?</h1>
<p>Please Enter Your Email. <br>
<!-- *************************************************BUTTON CSS *********************************************************-->
<style type="text/css">
#submit {
-moz-box-shadow:inset 0px 1px 0px 0px #efdcfb;
-webkit-box-shadow:inset 0px 1px 0px 0px #efdcfb;
box-shadow:inset 0px 1px 0px 0px #efdcfb;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #dfbdfa), color-stop(1, #bc80ea));
background:-moz-linear-gradient(top, #dfbdfa 5%, #bc80ea 100%);
background:-webkit-linear-gradient(top, #dfbdfa 5%, #bc80ea 100%);
background:-o-linear-gradient(top, #dfbdfa 5%, #bc80ea 100%);
background:-ms-linear-gradient(top, #dfbdfa 5%, #bc80ea 100%);
background:linear-gradient(to bottom, #dfbdfa 5%, #bc80ea 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfbdfa', endColorstr='#bc80ea',GradientType=0);
background-color:#dfbdfa;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
border:1px solid #337bc4;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:arial;
font-size:14px;
font-weight:bold;
padding:4px 10px;
text-decoration:none;
text-shadow:0px 1px 0px #528ecc;
}
#submit:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff));
background:-moz-linear-gradient(top, #378de5 5%, #79bbff 100%);
background:-webkit-linear-gradient(top, #378de5 5%, #79bbff 100%);
background:-o-linear-gradient(top, #378de5 5%, #79bbff 100%);
background:-ms-linear-gradient(top, #378de5 5%, #79bbff 100%);
background:linear-gradient(to bottom, #378de5 5%, #79bbff 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff',GradientType=0);
background-color:#378de5;
}
#submit:active {
position:relative;
top:1px;
}
</style>
<form name="email" action="confirm.asp" method="post">
<input type="email" name="email" size="30" required>
<input id="submit" type="submit" name="Submit" value="Reset">
</form>
</td></tr>
</table>
</center>
</td>
<td valign="top" background="images/pic_medacist_vrule_sp2.jpg" width="1"><img border="0" src="https://www.medacist.com/images/pic_medacist_vrule_02.jpg" width="7" height="667"></td>
</tr>
</table>
</td>
</tr>
<tr><td id="footer" valign="top">
<style type="text/css">
#footer{
background-repeat: no-repeat;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
background-image: url("../images/footer.gif");
font-size: 11px;
font-weight: bold;
height: 35px;
width: 650px;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<span id="copyrightMessage">© 1997 - 2015, Medacist Solutions Group, LLC. All rights reserved. U.S. Patent No. 6,842,736 entitled 'Drug Auditing Method and System'.
<br /> </span>
</td></tr>
</table>
</td>
</tr>
<tr><td valign="top"><img border="0" src="https://www.medacist.com/images/0_ghost.gif" width="20" height="20"></td></tr>
</table>
</div>
</body>
</html>
&#13;
<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual=reset_password.asp"-->
<html>
<head><title>Edit User Information</title></head>
<%
Dim oConn, oRs
Dim connectstr, sDSNDir, tablename
Dim db_name, db_username, db_userpassword
Dim dsn_name
dsn_name = "MySQL_TEST.dsn"
tablename = "medacist_user"
db_username = "chang"
db_userpassword = "PASSWORD123#"
sDSNDir = Server.MapPath("/_dsn")
connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim Message
EmailFrom = "clu@medacist.com"
EmailTo = Trim(Request.Form("email"))
Subject = "Here is your Password"
Message = "You're password is:" & objRS("Password" )
Dim validationOK
validationOK=true
If (validationOK=false) Then Response.Redirect("index.html")
Dim Body
Body = Body & message
Dim mail
Set mail = Server.CreateObject("CDOSYS.NewMail")
mail.To = EmailTo
mail.From = EmailFrom
mail.Subject = Subject
mail.Body = Body
mail.Send
Dim objRS, bolFound, strEmail
strEmail = Request.Form("email")
If strEmail = "" Then
oConn.Close
Set oConn = Nothing
Response.Write "<a href='reset_password.asp'>"
Response.Write "You must enter a email address"
Response.Write "</a>"
Response.End
End If
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "medacist_user", oConn, , , adCmdTable
bolFound = False
Do While Not (objRS.EOF OR bolFound)
If (StrComp(objRS("email"), strEmail, vbTextCompare) = 0) Then
BolFound = True
Else
objRS.MoveNext
End If
Loop
If Not bolFound Then
objRS.Close
Set objRS = Nothing
oConn.Close
Set oConn = Nothing
Response.Write "<a href='reset_password.asp'>"
Response.Write "Invalid Email Address.<p>"
Response.Write "</a>"
Response.End
End If
Dim objRS, bolFound, strEmail
strEmail = Request.Form("email")
If strEmail = "" Then
oConn.Close
Set oConn = Nothing
Response.Write "<a href='reset_password.asp'>"
Response.Write "You must enter a email address"
Response.Write "</a>"
Response.End
End If
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "medacist_user", oConn, , , adCmdTable
bolFound = False
Do While Not (objRS.EOF OR bolFound)
If (StrComp(objRS("Email"), strEmail, vbTextCompare) = 0) Then
BolFound = True
Else
objRS.MoveNext
End If
Loop
If Not bolFound Then
objRS.Close
Set objRS = Nothing
oConn.Close
Set oConn = Nothing
Response.Write "<a href='reset_password.asp'>"
Response.Write "Invalid Email Address.<p>"
Response.Write "</a>"
Response.End
End If
%>
</body>
</html>
&#13;