Skip to content Skip to sidebar Skip to footer

Asp Classic Connection String 500 - Internal Server Error

Hello I'm trying to connect to the oracle data source and seems like when i test the code its giving me an error. Also, I believe it might be my data source path is wrong. Is there

Solution 1:

MICROSOFT.JET.OLEDB.4.0 is the OLEDB provider for MS Access. You'll need either an ODBC or an OLEDB connection string for Oracle. See this page for options

http://www.connectionstrings.com/oracle/

After that you need a recordset object as kloarubeek suggests above. A very simple way to do this would be as follows.

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) 

Also I notice you are using CDONTS to send emails. It's deprecated and you won't find it on current versions of IIS by default. Look at CDOSYS instead

http://www.w3schools.com/asp/asp_send_email.asp

Finally, I recommend this page for anyone learning Classic ASP. It explains how to get error messages which are more useful than the basic 500 internal server error page.

http://www.chestysoft.com/asp-error-messages.asp

Edit

An example of a password retrieval script using CDOSYS and a recordset.

NB The CDO configuration will depend on your smtp server. Application("conn") means that my actual connection string is in a file called global.asa. This page actually connects to a SQL Server db, but the code should work with Oracle

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<% 
If InStr(request.form("username"),"@") > 0ThenSet 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
EndWith
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,1If 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


EndIf 

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")
EndIf

%>

Solution 2:

I update the code and try if work. And seems like result still the same error 500. I also add another asp file where user enter the email and click reset button direct to confirm.asp. What is wrong with my code.

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

     }
	
</STYLE><divalign="center"><tableborder="0"width="100"id="table1"cellspacing="0"cellpadding="0"><tr><tdvalign="top"><tableborder="0"width="100%"id="table2"cellspacing="0"cellpadding="0"><tr><tdvalign="top"><imgborder="0"src="https://www.medacist.com/images/pic_medacist_header.jpg"></td></tr><tr><tdvalign="top"><tableborder="0"width="100%"id="table3"cellspacing="0"cellpadding="0"><tr><tdvalign="top"bgcolor="#BBD6E7"><ahref="http://www.medacist.com/index.asp"><imgborder="0"src="https://www.medacist.com/images/pic_medacist_head_01.jpg"></a></td><tdvalign="top"bgcolor="#BBD6E7"><imgborder="0"src="https://www.medacist.com/images/pic_medacist_nav_08.jpg"></td></tr></table></td></tr><tr><tdvalign="top"><imgborder="0"src="https://www.medacist.com/images/pic_medacist_hrule_01.jpg"></td></tr><tr><tdvalign="top"bgcolor="#FFFFFF"><tableborder="0"width="100%"id="table4"cellspacing="0"cellpadding="0"><tr><tdvalign="top"><tableborder="0"width="100%"id="table6"cellspacing="0"cellpadding="0"><tr><tdvalign="top"><imgborder="0"src="https://www.medacist.com/images/pic_medacist_main_slogan.jpg"></td></tr><tr><tdvalign="top" ><center><tableclass="table1"width="100%"id="table8"cellspacing="0"cellpadding="0"></table><h1>Forgot Your Password?</h1><p>Please Enter Your Email. <br><!-- *************************************************BUTTON CSS *********************************************************--><styletype="text/css">#submit {
								-moz-box-shadow:inset 0px1px0px0px#efdcfb;
								-webkit-box-shadow:inset 0px1px0px0px#efdcfb;
								box-shadow:inset 0px1px0px0px#efdcfb;
								background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #dfbdfa), color-stop(1, #bc80ea));
								background:-moz-linear-gradient(top, #dfbdfa5%, #bc80ea100%);
								background:-webkit-linear-gradient(top, #dfbdfa5%, #bc80ea100%);
								background:-o-linear-gradient(top, #dfbdfa5%, #bc80ea100%);
								background:-ms-linear-gradient(top, #dfbdfa5%, #bc80ea100%);
								background:linear-gradient(to bottom, #dfbdfa5%, #bc80ea100%);
								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:4px10px;
								text-decoration:none;
								text-shadow:0px1px0px#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, #378de55%, #79bbff100%);
								background:-webkit-linear-gradient(top, #378de55%, #79bbff100%);
								background:-o-linear-gradient(top, #378de55%, #79bbff100%);
								background:-ms-linear-gradient(top, #378de55%, #79bbff100%);
								background:linear-gradient(to bottom, #378de55%, #79bbff100%);
								filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff',GradientType=0);
								background-color:#378de5;
							}
							#submit:active {
								position:relative;
								top:1px;
							}
				</style><formname="email"action="confirm.asp"method="post"><inputtype="email"name="email"size="30"required><inputid="submit"type="submit"name="Submit"value="Reset"></form></td></tr></table></center></td><tdvalign="top"background="images/pic_medacist_vrule_sp2.jpg"width="1"><imgborder="0"src="https://www.medacist.com/images/pic_medacist_vrule_02.jpg"width="7"height="667"></td></tr></table></td></tr><tr><tdid="footer"valign="top"><styletype="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><spanid="copyrightMessage">&copy; 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><tdvalign="top"><imgborder="0"src="https://www.medacist.com/images/0_ghost.gif"width="20"height="20"></td></tr></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 = "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 "<ahref='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 "<ahref='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 "<ahref='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 "<ahref='reset_password.asp'>"
    Response.Write "Invalid Email Address.<p>"
    Response.Write "</a>"
    Response.End
    End If
%>
    </body></html>

Post a Comment for "Asp Classic Connection String 500 - Internal Server Error"