经典的ASP连接字符串500

编程入门 行业动态 更新时间:2024-10-23 16:26:51
本文介绍了经典的ASP连接字符串500 - 内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,我试图连接到Oracle数据源,好像当我试code它给我一个错误。另外,我认为这可能是我的数据源路径是错误的。有没有办法来检查在Oracle或数据源路径中的任何一种方式?谢谢

\r\r

<! - 包含文件= reset_password.asp - >\r\r    <%\r    DIM strEmail\r    strEmail =的Request.Form(电子邮件)\r\r    IF strEmail<> 然后\r    %GT;\r    <! - #INCLUDE VIRTUAL =/包括/ connection.asp - >\r    <! - ************ SQL连接将这里********** - >\r    &所述;! - *******\r            设置objDB =的Server.CreateObject(ADODB.Connection)\r            objDB.openPROVIDER = MICROSOFT.JET.OLEDB.4.0;数据来源= C:\\了MyDatabase.mdb\r    **** - >\r\r    康涅狄格州。\r    <%\r\r    DIM objDB\r    objDB =SELECT EMAIL_ADDR,medacist_password FROM medacist_user WHERE EMAIL_ADDR ='&放大器; strEmail&安培; '\r    设置objDB =的Server.CreateObject(ADODB.Connection)\r    objDB.OpenPROVIDER = MICROSOFT.JET.OLEDB.4.0;数据来源= MMSG;坚持安全信息= TRUE;用户ID = MMSG;密码=兰加;\r\r    IF objDB.EOF THEN\r    RESPONSE.WRITE该电子邮件地址并不在我们的数据库中找到,请单击后退您的浏览器,输入您注册的邮件地址。\r    其他\r    DIM strPassword\r    strPassword = objDB(medacist_password)\r\r    DIM邮件,objMail\r    设置objMail =的Server.CreateObject(CDONTS.NewMail)\r    objMail.From =example@yahoo\r    objMail.Subject =您的密码\r    objMail.To = strEmail\r    objMail.Body =这里就是你的登陆密码:&放大器; strEmail\r    objMail.Send\r\r    '设置为objMail无关destory邮件对象\r    设置objMail =什么\r\r    RESPONSE.WRITE您的密码已发送到您的电子邮件地址。\r    万一\r\r    其他\r    RESPONSE.WRITE请单击后退您的浏览器,输入您注册的邮件地址。\r    END IF

\r\r\r

解决方案

MICROSOFT.JET.OLEDB.4.0是MS访问OLEDB提供商。您将需要一个ODBC或用于Oracle的OLEDB连接字符串。看到这个页面的选项

www.connectionstrings/oracle/

在你需要一个记录集对象klo​​arubeek上述建议。一个非常简单的方法来做到这将是如下:

DIM objDB,RS,RSSQL    设置objDB =的Server.CreateObject(ADODB.Connection)    objDB.Open[您的连接字符串到这里]    RSSQL =SELECT EMAIL_ADDR,medacist_password FROM medacist_user WHERE EMAIL_ADDR ='&放大器; strEmail&安培; '    集RS = objDB.Execute(RSSQL)

此外,我注意到你正在使用CDONTS发送电子邮件。这是pcated德$ P $,你不会发现它在默认情况下当前版本的IIS。看看CDOSYS而不是

www.w3schools/asp/asp_send_email.asp

最后,我建议这个页面的人学习经典ASP。它说明了如何让它们比基本500内部服务器错误页的更多有用的错误信息。

www.chestysoft/asp-error-messages.asp

修改

使用CDOSYS和记录密码检索脚本的一个例子。

NB的CDO配置将取决于您的SMTP服务器上。应用程序(参数conn),意味着我的实际的连接字符串是在一个名为Global.asa中。此页面实际连接到SQL Server数据库,但code应与Oracle合作

<%@ LANGUAGE =VBSCRIPTcodePAGE =65001%><%如果INSTR(的Request.Form(用户名),@)> 0,则设置objMail =的Server.CreateObject(CDO.Message)设置iConfg =的Server.CreateObject(CDO.Configuration)设置FLDS = iConfg.Fields随着FLDS        .Item(schemas.microsoft/cdo/configuration/sendusing)= 2        .Item(schemas.microsoft/cdo/configuration/smtpserver)=127.0.0.1        .Item(schemas.microsoft/cdo/configuration/smtpserverport)= 587        .Item(schemas.microsoft/cdo/configuration/smtpauthenticate)= 1        .Item(schemas.microsoft/cdo/configuration/sendusername)=youremailusername        .Item(schemas.microsoft/cdo/configuration/sendpassword)=youremailpasword    .Update结束与objMail.Configuration = iConfgobjMail.To = CStr的(的Request.Form(用户名))objMail.From =you@yourdomainobjMail.Subject =您的登录信息objMail.TextBody =您的登录详细信息如下与& vbcrlf&安培; vbcrlf康涅狄格州设置=的Server.CreateObject(ADODB.Connection)conn.open应用程序(参数conn)SQL =&AMP从联系人那里ContactEmailAddress ='​​选择ContactEmailAddress,ContactAffiliateUsername,ContactAffiliatePassword的request.form(用户名)及'设置RS =的Server.CreateObject(ADODB.Recordset)rs.open SQL,康涅狄格州,3,1如果rs.bof而RS.EOF然后的Response.Redirect(invalidemailpage.asp?invalidemail = 2)其他objMail.To = RS(ContactEmailAddress)objMail.TextBody = objMail.TextBody&安培; 用户名=&放大器; RS(ContactAffiliateUsername)及,密码=与& RS(ContactAffiliatePassword)及vbcrlf万一objMail.Send设置objMail =什么rs.close集RS =什么conn.close康涅狄格州设置什么=的Response.Redirect(的login.asp?sentpassword = 1)其他的Response.Redirect(invalidemailpage.asp?invalidemail = 1)万一%GT;

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 way to check the data source path in oracle or any kind of way? Thanks

<!--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" 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

解决方案

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

www.connectionstrings/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

www.w3schools/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.

www.chestysoft/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"),"@") > 0 Then Set objMail = Server.CreateObject("CDO.Message") Set iConfg = Server.CreateObject("CDO.Configuration") Set Flds = iConfg.Fields With Flds .Item("schemas.microsoft/cdo/configuration/sendusing") = 2 .Item("schemas.microsoft/cdo/configuration/smtpserver") = "127.0.0.1" .Item("schemas.microsoft/cdo/configuration/smtpserverport") = 587 .Item("schemas.microsoft/cdo/configuration/smtpauthenticate") = 1 .Item("schemas.microsoft/cdo/configuration/sendusername") = "youremailusername" .Item("schemas.microsoft/cdo/configuration/sendpassword") = "youremailpasword" .Update End With objMail.Configuration = iConfg objMail.To = CStr(request.form("username")) objMail.From = "you@yourdomain" 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 %>

更多推荐

经典的ASP连接字符串500

本文发布于:2023-10-30 22:47:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544224.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   经典   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!