2015-01-02 2 views
-1

Привет, я пытаюсь подключиться к источнику данных oracle и, похоже, когда я проверяю код, он дает мне ошибку. Кроме того, я считаю, что это может быть неправильный путь источника данных. Есть ли способ проверить путь источника данных в oracle или любым способом? БлагодаряAsp Classic Connection String 500 - Внутренняя ошибка сервера

<!--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 = "[email protected]" 
 
    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

+0

вы проверили линию, которая вызывает эту ошибку 500? Я вижу много проблем в этом коде, даже если у вас есть соединение, оно не будет работать: вам нужно соединение и набор записей, теперь вы рассматриваете соединение как набор записей. Сначала прочитайте об ADO: https://www.webwiz.co.uk/kb/asp-tutorials/connecting-to-an-access-database.htm (да, это db доступа, но для Oracle только строка соединения отличается). – kloarubeek

ответ

1

Microsoft.Jet.OLEDB.4.0 является поставщиком OLEDB для MS Access. Для 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. Приложение («conn») означает, что моя фактическая строка подключения находится в файле global.asa. Эта страница действительно подключается к SQL-серверу, но код должен работать с 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 = "[email protected]" 
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 

%> 
+0

Спасибо за помощь. Я изменил настройку. Но я все равно получаю ту же ошибку. – Random

+0

DIM objDB, rssql Set objDB = Server.CreateObject ("ADODB.Connection") objDB.Open "Provider = MSDASQL.1; Password = langas; Persist Security Info = True; User ID = mmsg; Источник данных = mmsg_web " rssql =" SELECT email_addr, medacist_password FROM medacist_user WHERE email_addr = '"& strEmail &"' " – Random

+0

Включили ли вы подробные сообщения об ошибках по моему последнему предложению. Есть всевозможные вещи, которые могут вызвать ошибку, которые помогут вам определить ее. – John

0

Я обновляю код и пытаюсь работать. И похоже, что результат все тот же ошибки 500. Я также добавляю еще один asp-файл, где пользователь вводит адрес электронной почты и нажимает кнопку сброса прямо на confirm.asp. Что не так с моим кодом.

<html> 
 
<head> 
 
\t <title> Reset Password</title> 
 
</head> 
 
<body> 
 
\t <STYLE type="text/css"> 
 
     BODY { 
 
    background: #B4D7EB url("https://www.medacist.com/images/pic_medacist_gradient.jpg"); 
 
    background-attachment: fixed; 
 
    background-repeat: repeat-x; 
 
\t background-attachment: scroll; 
 

 
    } 
 
\t 
 
</STYLE> 
 
<div align="center"> 
 
\t <table border="0" width="100" id="table1" cellspacing="0" cellpadding="0"> 
 
\t \t <tr> 
 
\t \t \t <td valign="top"> 
 
\t \t \t <table border="0" width="100%" id="table2" cellspacing="0" cellpadding="0"> 
 
\t \t \t \t <tr><td valign="top"><img border="0" src="https://www.medacist.com/images/pic_medacist_header.jpg"></td></tr> 
 
\t \t \t \t <tr><td valign="top"> 
 
\t \t \t \t \t <table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0"> 
 
\t \t \t \t \t \t <tr> 
 
\t \t \t \t \t \t \t <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> 
 
\t \t \t \t \t \t 
 
\t \t \t \t 
 
\t \t \t \t \t \t \t <td valign="top" bgcolor="#BBD6E7"><img border="0" src="https://www.medacist.com/images/pic_medacist_nav_08.jpg"></td> 
 
\t \t \t \t \t \t </tr> 
 
\t \t \t \t \t </table> 
 
\t \t \t \t </td></tr> 
 
\t \t \t \t <tr><td valign="top"><img border="0" src="https://www.medacist.com/images/pic_medacist_hrule_01.jpg"></td></tr> 
 
\t \t \t \t <tr><td valign="top" bgcolor="#FFFFFF"> 
 
\t \t \t \t \t <table border="0" width="100%" id="table4" cellspacing="0" cellpadding="0"> 
 
\t \t \t \t \t \t <tr><td valign="top"> 
 
\t \t \t \t \t \t \t <table border="0" width="100%" id="table6" cellspacing="0" cellpadding="0"> 
 
\t \t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t \t <tr><td valign="top"><img border="0" src="https://www.medacist.com/images/pic_medacist_main_slogan.jpg"></td></tr> 
 
\t \t \t \t \t \t \t \t <tr><td valign="top" > 
 
\t \t \t \t \t <center> \t \t \t \t \t \t \t \t 
 
\t <table class="table1" width="100%" id="table8" cellspacing="0" cellpadding="0"> 
 
\t \t \t </table> 
 
\t \t \t <h1>Forgot Your Password?</h1> 
 
\t \t \t <p>Please Enter Your Email. <br> 
 
\t \t \t \t 
 
\t \t \t \t <!-- *************************************************BUTTON CSS *********************************************************--> 
 
\t \t \t \t <style type="text/css"> 
 

 

 
      \t \t \t  #submit { 
 
\t \t \t \t \t \t \t \t -moz-box-shadow:inset 0px 1px 0px 0px #efdcfb; 
 
\t \t \t \t \t \t \t \t -webkit-box-shadow:inset 0px 1px 0px 0px #efdcfb; 
 
\t \t \t \t \t \t \t \t box-shadow:inset 0px 1px 0px 0px #efdcfb; 
 
\t \t \t \t \t \t \t \t background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #dfbdfa), color-stop(1, #bc80ea)); 
 
\t \t \t \t \t \t \t \t background:-moz-linear-gradient(top, #dfbdfa 5%, #bc80ea 100%); 
 
\t \t \t \t \t \t \t \t background:-webkit-linear-gradient(top, #dfbdfa 5%, #bc80ea 100%); 
 
\t \t \t \t \t \t \t \t background:-o-linear-gradient(top, #dfbdfa 5%, #bc80ea 100%); 
 
\t \t \t \t \t \t \t \t background:-ms-linear-gradient(top, #dfbdfa 5%, #bc80ea 100%); 
 
\t \t \t \t \t \t \t \t background:linear-gradient(to bottom, #dfbdfa 5%, #bc80ea 100%); 
 
\t \t \t \t \t \t \t \t filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfbdfa', endColorstr='#bc80ea',GradientType=0); 
 
\t \t \t \t \t \t \t \t background-color:#dfbdfa; 
 
\t \t \t \t \t \t \t \t -moz-border-radius:5px; 
 
\t \t \t \t \t \t \t \t -webkit-border-radius:5px; 
 
\t \t \t \t \t \t \t \t border-radius:5px; 
 
\t \t \t \t \t \t \t \t border:1px solid #337bc4; 
 
\t \t \t \t \t \t \t \t display:inline-block; 
 
\t \t \t \t \t \t \t \t cursor:pointer; 
 
\t \t \t \t \t \t \t \t color:#ffffff; 
 
\t \t \t \t \t \t \t \t font-family:arial; 
 
\t \t \t \t \t \t \t \t font-size:14px; 
 
\t \t \t \t \t \t \t \t font-weight:bold; 
 
\t \t \t \t \t \t \t \t padding:4px 10px; 
 
\t \t \t \t \t \t \t \t text-decoration:none; 
 
\t \t \t \t \t \t \t \t text-shadow:0px 1px 0px #528ecc; 
 
\t \t \t \t \t \t \t } 
 
\t \t \t \t \t \t \t #submit:hover { 
 
\t \t \t \t \t \t \t \t background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff)); 
 
\t \t \t \t \t \t \t \t background:-moz-linear-gradient(top, #378de5 5%, #79bbff 100%); 
 
\t \t \t \t \t \t \t \t background:-webkit-linear-gradient(top, #378de5 5%, #79bbff 100%); 
 
\t \t \t \t \t \t \t \t background:-o-linear-gradient(top, #378de5 5%, #79bbff 100%); 
 
\t \t \t \t \t \t \t \t background:-ms-linear-gradient(top, #378de5 5%, #79bbff 100%); 
 
\t \t \t \t \t \t \t \t background:linear-gradient(to bottom, #378de5 5%, #79bbff 100%); 
 
\t \t \t \t \t \t \t \t filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff',GradientType=0); 
 
\t \t \t \t \t \t \t \t background-color:#378de5; 
 
\t \t \t \t \t \t \t } 
 
\t \t \t \t \t \t \t #submit:active { 
 
\t \t \t \t \t \t \t \t position:relative; 
 
\t \t \t \t \t \t \t \t top:1px; 
 
\t \t \t \t \t \t \t } 
 
\t \t \t \t </style> 
 

 
\t \t \t <form name="email" action="confirm.asp" method="post"> 
 
\t \t \t <input type="email" name="email" size="30" required> 
 
\t \t \t <input id="submit" type="submit" name="Submit" value="Reset"> 
 
\t \t \t </form> 
 
\t \t </td></tr> 
 
\t \t </table> 
 
\t \t </center> 
 

 
\t \t \t \t </td> 
 
\t \t \t \t <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> 
 
\t \t \t \t </tr> 
 
\t \t \t \t \t </table> 
 
\t \t \t \t \t </td> 
 
\t \t \t \t </tr> 
 
\t \t \t \t <tr><td id="footer" valign="top"> 
 
\t \t \t \t \t <style type="text/css"> 
 
\t \t \t \t \t \t #footer{ 
 
\t \t \t \t \t \t \t 
 

 
\t \t \t \t \t \t \t background-repeat: no-repeat; 
 
\t \t \t \t \t \t \t border-bottom-left-radius: 20px; 
 
\t \t \t \t \t \t \t border-bottom-right-radius: 20px; 
 
\t \t \t \t \t \t \t background-image: url("../images/footer.gif"); 
 
\t \t \t \t \t \t \t font-size: 11px; 
 
\t \t \t \t \t \t \t font-weight: bold; 
 
\t \t \t \t \t \t \t height: 35px; 
 
\t \t \t \t \t \t \t width: 650px; 
 
\t \t \t \t \t \t \t text-align: center; 
 
\t \t \t \t \t \t \t font-family: Arial, Helvetica, sans-serif; 
 

 
\t \t \t \t \t \t } 
 

 
\t \t \t \t \t 
 
\t \t \t \t \t </style> 
 
\t \t \t \t \t <span id="copyrightMessage">&copy; 1997 - 2015, Medacist Solutions Group, LLC. All rights reserved. U.S. Patent No. 6,842,736 entitled 'Drug Auditing Method and System'. 
 
\t \t \t \t \t <br /> </span> 
 
\t \t \t \t </td></tr> 
 
\t \t \t </table> 
 
\t \t \t </td> 
 
\t \t </tr> 
 
\t \t <tr><td valign="top"><img border="0" src="https://www.medacist.com/images/0_ghost.gif" width="20" height="20"></td></tr> 
 
\t </table> 
 
</div> 
 
</body> 
 
</html>

<%@ 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 = "[email protected]" 
 
    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>

Смежные вопросы