Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: I dont understand this error


Message #1 by "Paul B" <lead_5@h...> on Fri, 1 Feb 2002 00:38:22
Hello



I have just added a new field to a table in my database, and the new 

coding to my asp page to add that field.



Unfortunately I keep getting the same recuring error, even though the 

coding is correct (to my knowledge anyway).



Here is the code which I think causes the problem:



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

	cmdDC.ActivateConnection = DataConn

	cmdDC.CommandText = "SELECT ProvideCode FROM Provider WHERE 

Provider='" & Prov & "';"

	cmdDC.CommandType = 1

	Set rsDC = Server.CreateObject("ADODB.Recordset")

	rsDC.Open cmdDC, , 0, 1

	PC=rsDC.fields(0).value

	rsDC.close

	set rsDC=nothing



But this code is almost exactly the same as the other bits of code which 

opens up tables, but this one doesn't work.



Can anyone help me?

The error message I get is below, and the whole code is below that.



Any help would be greatly appreciated, thank you.

Paul



VBS Error Number: 3219'VBS Error Description: The operation requested by 

the application is not allowed in this context.' 





<%response.buffer=true%>

<HTML>

<BODY>

	<%

on error resume next



	Code=request.querystring("DonarCode")

	Contact=request.querystring("DonarContact")

	SubCode=request.querystring("SubjectCode")

	ComCode=request.querystring("ComponentCode")

	Comment=request.querystring("ComponentComment")

	Number=request.querystring("DonatedNumber")

	Prov=request.querystring("ProvideCode")

	Valid="No"

	Archive="No"	

	TheDate=date()



	IF Comment="" THEN

		Comment="Nil"

	End If

       

	IF len(Comment)>50 THEN%>

             You have place to much text in the comment field, please 

restrict it to less than 50 characters.

             Please<A href='addno.asp'>Try again</a>

	<%response.end

        End If

  

	IF Number ="" THEN%>

	Sorry, that is an invaild number!<br><br>

	Please<A href='addno.asp'> Try again</a>

	<%response.end

        End If

	

	If Contact ="" then%>

	Sorry, the database doesn't seem to have a contact name specified!

<br><br>

	Please <A href='addno.asp'>return</a> and enter one in.

	<%response.end

        End If



	IF len(Contact)>20 THEN%>

             You have placed to much text in the contact field, please 

restrict it to less than 20 characters.

             Please <A href='addno.asp'>Try again</a>

	<%response.end

        End If

        

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

   	DataConn.Open "DBQ=" & server.mappath("../data/data.mdb") 

& ";Driver={Microsoft Access Driver 

(*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20;"



 

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

   	cmdDC.ActiveConnection = DataConn

   	cmdDC.CommandText = "SELECT SubjectCode FROM Subject WHERE 

Subject='" & SubCode & "';" 

   	cmdDC.CommandType = 1

	Set rsDC = Server.CreateObject("ADODB.Recordset")

   	rsDC.Open cmdDC, , 0, 1

	Subject=rsDC.fields(0).value

   	rsDC.close

    	set rsDC=nothing



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

	cmdDC.ActivateConnection = DataConn

	cmdDC.CommandText = "SELECT ProvideCode FROM Provider WHERE 

Provider='" & Prov & "';"

	cmdDC.CommandType = 1

	Set rsDC = Server.CreateObject("ADODB.Recordset")

	rsDC.Open cmdDC, , 0, 1

	PC=rsDC.fields(0).value

	rsDC.close

	set rsDC=nothing

	

	cmdDC.CommandText = "SELECT ComponentCode FROM Component WHERE 

Component='" & ComCode & "';" 

	cmdDC.CommandType = 1

	Set rsDC = Server.CreateObject("ADODB.Recordset")

        rsDC.Open cmdDC, , 0, 1

	CCode=rsDC.fields(0).value

   	rsDC.close

    	set rsDC=nothing

        Set cmdDC = Nothing

        DataConn.Close

        Set DataConn = Nothing

	Dim DB_CONNECTION_STRING

	DB_CONNECTION_STRING = "DRIVER={Microsoft Access Driver 

(*.mdb)};DBQ=" & Server.Mappath("../data/data.mdb") & ";"



	%>

		<!-- #INCLUDE FILE="adovbs.inc" -->

	<%	



	Dim objRecordset

	Set objRecordset = Server.CreateObject("ADODB.Recordset")



	objRecordset.Open "DonationsForProvider", DB_CONNECTION_STRING, 

adOpenStatic, adLockPessimistic, adCmdTable



	objRecordset.AddNew



	objRecordset.Fields("DonarCode") = CStr(Code)

	objRecordset.Fields("DonarContact") = CStr(Contact)

	objRecordset.Fields("DonationDate") = date()

	objRecordset.Fields("ComponentCode")=CStr(CCode)

	objRecordset.Fields("ComponentComment") = CStr(Comment)

	objRecordset.Fields("DonationNumber") = CStr(Number)	

	objRecordset.Fields("Available") = CStr(Number)

	objRecordset.Fields("SubjectCode") = CStr(Subject)

	objRecordset.Fields("ProvideCode") = CStr(PC)

	objRecordset.Update

	objRecordset.Close

	Set objRecordset = Nothing





IF err <> 0 THEN 'err can be positive or negative

  RESPONSE.WRITE "VBS Error Number: " & err.number & "'" 

  RESPONSE.WRITE "VBS Error Description: " & err.description & "'" 

  RESPONSE.WRITE "ADO Error Number: " & objConnection.errors(0).number 

& "'" 

  RESPONSE.WRITE "ADO Error Description: " & objConnection.errors 

(0).description & "<br>" 

else

 	response.redirect "mainchoose.asp"

end if 





%>



</BODY>

</HTML>







Message #2 by "Ken Schaefer" <ken@a...> on Fri, 1 Feb 2002 11:41:03 +1100
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "Paul B" <lead_5@h...>

Subject: [access_asp] I dont understand this error





: Hello

:

: I have just added a new field to a table in my database, and the new

: coding to my asp page to add that field.

:

: Unfortunately I keep getting the same recuring error, even though the

: coding is correct (to my knowledge anyway).

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



<snipped for your viewing comfort>



Take out On Error Resume Next. Run the code again. Post the error you now

see with the line number.



Cheers

Ken





Message #3 by "Paul B" <lead_5@h...> on Tue, 5 Feb 2002 01:50:13
Thanks for your reply Ken.



I managed to figure out the problem myself (after many days), I was 

opening another connection when I had one already open.



Thanks

Paul





> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> From: "Paul B" <lead_5@h...>

> Subject: [access_asp] I dont understand this error

> 

> 

> : Hello

> :

> : I have just added a new field to a table in my database, and the new

> : coding to my asp page to add that field.

> :

> : Unfortunately I keep getting the same recuring error, even though the

> : coding is correct (to my knowledge anyway).

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

> <snipped for your viewing comfort>

> 

> Take out On Error Resume Next. Run the code again. Post the error you now

> see with the line number.

> 

> Cheers

> Ken

> 

> 


  Return to Index