473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Query timeout expired when doing update to password to a field

Hi all,

Does anyone have an idea to solve this problem in asp? I have tried to look everywhere for the last week but no one seems to have the answer.

The issue is that I have the script below that is used to generate new password which is the encripted to update the password field in the database. It then suprisingly times out when used with sql server and the field is not updated, however, if you use the access database, the password field is updated and the new password is sent to the user.

Which means that the issue could be on the rs handling and sql...

Please help, or advice...

Cheers,

Erick

Expand|Select|Wrap|Line Numbers
  1.  <!--#include file="include/clean.asp"-->
  2. <!--#include file="include/dbcommon.asp"-->
  3. <!--#include file="include/md5.asp"-->
  4. <!--#include file="libs/xtempl.asp"-->
  5. <%
  6. if SESSION("count_captcha")="" or SESSION("count_captcha")>5 then SESSION("count_captcha")=0
  7.  
  8. dim xt
  9. set xt = new XTempl
  10. cEmailField = "Email (mail)"
  11. reminded=false
  12. strSearchBy="username"
  13.  
  14. strUsername=""
  15. strEmail=""
  16. strMessage=""
  17.  
  18. dbConnection=""
  19. db_connect()
  20. DoEvent "BeforeProcessRemind dbConnection"
  21.  
  22.  
  23. if request.form("btnSubmit") = "Remind" then
  24.     strSearchBy=request.Form("searchby")
  25.     'strUsername=request.Form("username")
  26.     strUsername = cleanName(request.Form("username"))
  27.     strEmail=request.Form("email")
  28.        Set rstemp = server.CreateObject("ADODB.Recordset")
  29.        Set rs = server.CreateObject("ADODB.Recordset")
  30.  
  31.     rstemp.open "select * from [Staff Details] where 1=0",dbConnection,1,2
  32.  
  33.     tosearch=false
  34.     if strSearchBy<>"email" then
  35.         value=strUsername
  36.         if cstr(value)<>"" then tosearch=true
  37.         if FieldNeedQuotes(rstemp,cUserNameField) then 
  38.             value="'" & db_addslashes(value) & "'"
  39.         else
  40.             value=my_numeric(value)
  41.         end if
  42.         sWhere=AddFieldWrappers(cUserNameField) & "=" & value
  43.     else
  44.         value=strEmail
  45.         if cstr(value)<>"" then tosearch=true
  46.         if FieldNeedQuotes(rstemp,cEmailField) then
  47.             value="'" & db_addslashes(value) & "'"
  48.         else
  49.             value=my_numeric(value)
  50.         end if
  51.         sWhere=AddFieldWrappers(cEmailField) & "=" & value
  52.     end if
  53.  
  54.     if tosearch then DoEvent "tosearch = BeforeRemindPassword(strUsername,strEmail)"
  55.  
  56.  
  57.     if tosearch then
  58.  
  59.         strSQL="select " & AddFieldWrappers(cUserNameField) & "," & AddFieldWrappers(cPasswordField) & "," & AddFieldWrappers(cEmailField) & " from [Staff Details] where " & sWhere
  60.         rs.Open strSQL,dbConnection,1,2
  61.         'set rs = server.createobject("adodb.recordset")
  62.         'rs.open strSQL, dbConnection,1,2
  63.         if not rs.EOF then
  64.             password=rs(1)
  65. '//    generate 6 letters length password
  66.             password=""
  67.             randomize
  68.             for ind=0 to 5
  69.                 j=rnd(35)
  70.                 if j<26 then
  71.                     password=password & chr(asc("a")+j)
  72.                 else
  73.                     password=password & chr(asc("0")-26+j)
  74.                 end if
  75.  
  76.             next
  77.             dbConnection.Execute "update [Staff Details] set " & AddFieldWrappers(cPasswordField) & "='" & md5(password) & "' where " & sWhere
  78.             'response.Write(password)
  79.             'response.End()
  80.             'j
  81.             url = "http://" & request.ServerVariables("SERVER_NAME")
  82.             if CStr(request.ServerVariables("SERVER_PORT"))<>"80" then _
  83.                 url = url & ":" & request.ServerVariables("SERVER_PORT")
  84.             url= url & request.ServerVariables("SCRIPT_NAME")
  85.             message="Password reminder" & vbcrlf
  86.             message=message & "You asked to remind your username and password at" & " " & url & vbcrlf
  87.             message=message & "Username" & " " & rs(0) & vbcrlf
  88.             message=message & "Password" & " " & password & vbcrlf
  89.             sendmail rs(2),"Password reminder",message
  90.             reminded=true
  91.             DoEvent "AfterRemindPassword strUsername,strEmail"
  92.             loginlink_attrs="href=""login.asp"
  93.             if strSearchBy<>"email" then loginlink_attrs=loginlink_attrs & "?username=" & server.HTMLEncode(strUsername)
  94.             loginlink_attrs=loginlink_attrs & """"
  95.             xt.assign "loginlink_attrs",loginlink_attrs
  96.             xt.assign "body",true
  97.             SESSION("count_captcha")=SESSION("count_captcha")+1
  98.             xt.display("remind_success.htm")
  99.             response.End
  100.         end if
  101.     end if
  102.  
  103.     if not reminded then
  104.         if strSearchBy<>"email" then
  105.             strMessage="User" & " <i>" & strUsername & "</i> " & "is not registered."
  106.         else
  107.             strMessage="This email doesn't exist in our database"
  108.         end if
  109.     end if
  110.  
  111. end if
  112.  
  113. emailradio_attrs="onclick=""document.forms.form1.searchby.value='email'; UpdateControls();"""
  114. usernameradio_attrs="onclick=""document.forms.form1.searchby.value='username'; UpdateControls();"""
  115.  
  116. if strSearchBy="username" then
  117.     usernameradio_attrs=usernameradio_attrs & " checked"
  118.     search_disabled = "email"
  119. end if
  120.  
  121. xt.assign "emailradio_attrs",emailradio_attrs
  122. xt.assign "usernameradio_attrs",usernameradio_attrs
  123.  
  124. xt.assign "username_attrs","value=""" & my_htmlspecialchars(strUsername) & """"
  125. xt.assign "email_attrs","value=""" & my_htmlspecialchars(strEmail) & """"
  126. if strMessage<>"" then
  127.     xt.assign "message",strMessage
  128.     xt.assign "message_block",true
  129.     if captcha=1 then SESSION("count_captcha")=SESSION("count_captcha")+1
  130. end if
  131.  
  132. set body=CreateObject("Scripting.Dictionary")
  133. str="<script language = JavaScript>"
  134. str=str & "function OnKeyDown(){"
  135. str=str & "e = window.event;"
  136. str=str & "if (e.keyCode == 13){"
  137. str=str & "e.cancel = true;"
  138. str=str & "document.forms[0].submit();}}"
  139. str=str & "function UpdateControls(){"
  140. str=str & "if (document.forms.form1.searchby.value==""username""){"
  141. str=str & "document.forms.form1.username.style.backgroundColor='white';"
  142. str=str & "document.forms.form1.email.style.backgroundColor='gainsboro';"
  143. str=str & "document.forms.form1.username.disabled=false;"
  144. str=str & "document.forms.form1.email.disabled=true;}else{"
  145. str=str & "document.forms.form1.username.style.backgroundColor='gainsboro';"
  146. str=str & "document.forms.form1.email.style.backgroundColor='white';"
  147. str=str & "document.forms.form1.username.disabled=true;"
  148. str=str & "document.forms.form1.email.disabled=false;}}</script>"
  149. str=str & "<form method=post action=""remind.asp"" id=form1 name=form1>"
  150. str=str & "<input type=hidden name=btnSubmit value=""Remind"">"
  151. str=str & "<input type=""Hidden"" name=""searchby"" value=""" & strSearchBy & """>"
  152. body("begin")=str
  153. body("end")="</form><script language=""JavaScript"">document.forms.form1." & search_disabled & ".disabled=false;    UpdateControls();</script>"
  154. xt.assign "body",body
  155.  
  156.  
  157. templatefile = "remind.htm"
  158. DoEvent "BeforeShowRemindPwd xt,templatefile"
  159. xt.display(templatefile)
  160. %> 
Apr 25 '11 #1
2 2955
jhardman
3,406 Expert 2GB
just some basic troubleshooting steps:

Can you query or execute a static command to your sql server? in other words, does "select * from [Staff Details]" work? Does a static update command like "update [staff Details] set pword = 'asdf1' where idnum=3" work?

Jared
Apr 25 '11 #2
Dear Jared,

thanks for the reply, I have queried this
Expand|Select|Wrap|Line Numbers
  1. update [Staff Details] set [password]='MD5 hash value' where [username]='admin'
which is generated when I did response write in the sql server but yes it is indicating that it is executed but when you use the password which was sent after the generated one it still seems the field was not updated.

There is no error though which is generated, so I still do not understand why the password field does not update with the new encrypted one. The sql query indicates "Query successfully executed" and one "rows affected".

Also, I have tried "select * from [Staff Details]" query and it works pretty well returning all the values in the table

Thanks in advance

Erick
Apr 26 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: heruti | last post by:
Hi all... I've been stumped by this for days. Bit of ASP code: (IIS) Set LocalConn = CreateObject("ADODB.Connection") LocalConn.CursorLocation = adUseClient LocalConn.CommandTimeout = 0...
1
by: Resant | last post by:
Hi All, I have a problem with my Server since I've install Terminal Services. Sometimes my users get error 'Timeout expired' when trying to query or open program. Whatshould I do to increase the...
0
by: Shahab Gerami | last post by:
Hi I get SQLException of Timeout expired when the Sp takes more than 30 seconds to run. I already put the Connect Time = 300 and CommandTimeout = 300, but still Iget the same error. Any...
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
3
by: Nils Magnus Englund | last post by:
Hi, I've made a HttpModule which deals with user authentication. On the first request in a users session, it fetches data from a SQL Server using the following code: using (SqlConnection...
4
by: VB Programmer | last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When I precomile it to my web deployment project and then copy the debug files to my web server I get this problem when trying...
1
by: mike11d11 | last post by:
I'm doing a simple TableAdapter.Fill filling my datatable from a view within a SQL database. for some reason it is timing out after 30 seconds and I cant seem to find out where in vb.net 2005 I...
4
by: mabubakarpk | last post by:
Hello to all I am using an application which is in vb6.0 and database in MSSQL server 2k. I am using connection string through ADO. Some times I receive message...
1
by: Charl | last post by:
Hi I have a small VB.Net app that needs to process data from a SQL 2005 DB. All works well when I limit the number of rows returned by the stored procedure to less than 300 (select top 300...) . As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.