Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Active Server Pages, ASP 0113 (0x80004005)


Message #1 by "Matt" <pelm@v...> on Fri, 23 Nov 2001 06:11:25
Hi!



I am making a simple web page that adds e-mail adress to a very simple 

database to have a newsletter on my site.  When I use that page for the 

first time it works really well and the data is added to the access 

database.  But if I ever try to add more data, I get this error :

Active Server Pages, ASP 0113 (0x80004005)

The maximum amount of time for a script to execute..........



I really don't know what is the problem since I run that script on my own 

computer. The problem cannot be related to a speed or time question, but 

more an error I must have made.  But what is it?



Here is the complete code (I know it is not really good code but I'll make 

it better by the time I get it to work fine...)



' This page is opened by an html e-mail so that is why I use QuerySting...

Dim strEmail, strType, strLanguage

strEmail= Trim(Request.QueryString("email")) ' Trimmed in case the user 

accidentally added spaces

strType= Trim(Request.QueryString("type"))

strLanguage= Trim(Request.QueryString("lang"))



CONST SELECT_NEWS= "SELECT NEWS.NEWS_EMAIL, NEWS.NEWS_TYPE, 

NEWS.NEWS_LANGUAGE FROM NEWS;"



Dim siteConn

Set siteConn= Server.CreateObject("ADODB.Connection") 

siteConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & 

Server.MapPath("Data\site.mdb")



' Create the command and put SQL query in it

Dim objCommand

Set objCommand= Server.CreateObject("ADODB.Command")

objCommand.ActiveConnection= siteConn

objCommand.CommandText= SELECT_NEWS

objCommand.CommandType= adCmdText



' Create the record set and execute the SQL query

Dim objRS

Set objRS= objCommand.Execute

	

Dim emailExists

emailExists= False



While Not objRS.EOF AND Not emailExists

	If objRS("NEWS_EMAIL") = strEmail Then

		emailExists= True

	End If

Wend



objRS.Close

Set objRS= Nothing

Set objCommand= Nothing



If Not emailExists Then

	CONST INSERT_NEWS= "INSERT INTO NEWS VALUES ("



	' Create the command and put SQL query in it

	Dim objCommand2

	Set objCommand2= Server.CreateObject("ADODB.Command")

	objCommand2.ActiveConnection= siteConn

	objCommand2.CommandText= INSERT_NEWS & "'" & strEmail & "', '" & 

strType & "', '" & strLanguage & "')"

	objCommand2.CommandType= adCmdText

	objCommand2.Execute

	

	Set objCommand2= Nothing

End If



siteConn.Close

Set siteConn= Nothing

' End of script...



Thanks!

Matt.
Message #2 by "Ken Schaefer" <ken@a...> on Fri, 23 Nov 2001 22:51:00 +1100
Here's a hint before I look at your code...



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: CONST SELECT_NEWS= "SELECT NEWS.NEWS_EMAIL, NEWS.NEWS_TYPE,

: NEWS.NEWS_LANGUAGE FROM NEWS;"

:

: objCommand.CommandText= SELECT_NEWS

: Set objRS= objCommand.Execute

:

: Dim emailExists

: emailExists= False

:

: While Not objRS.EOF AND Not emailExists

: If objRS("NEWS_EMAIL") = strEmail Then

: emailExists= True

: End If

: Wend

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



is pretty painful. Try to keep in mind that databases work in sets, not in

cursors.

How about attempting to return a set of data that matches your criteria, and

seeing if that set exists?



<%

strSQL = _

    "SELECT a.News_Email, a.News_Type, a.News_Languages " & _

    "FROM News a" & _

    "WHERE a.News_Email = '" & strEmail & "'"



objRS.Open strSQL, objConn, adOpenForwardOnly, adLockReadOnly, adCmdText



If objRS.EOF then

    ' There is no match

Else

    ' There is a match

End If



objRS.Close

Set objRS = Nothing



objConn.Close

Set objConn = Nothing

%>



Cheers

Ken





Message #3 by "Matt" <pelm@v...> on Fri, 23 Nov 2001 16:10:19
Doh!



Sometimes simple errors can be very frustrating.  It works very fine now.  

I don't understand why I wrote that code that way.  I know SQL, databases 

and recordsets very well (as well as programming).  I don't understand why 

I did that extremely poor code.



Well, thanks!

Matt.

  Return to Index