ASP Questions

Sam scorder at incigna.com
Thu Jul 13 12:24:38 EDT 2000


On 13 Jul 2000 10:35:18 GMT, gbreed at cix.compulink.co.uk wrote:

>Here are some outstanding problems I have with ASP files written in 
>Python.  Hopefully, some of you will have solutions.
>
>I can't write to session or application variables.  In VBScript, this is 
>done like Session("key")="value".  In Python, for writing to a new key, 
>that translates to assignment to None.  I found some documentation for 
>fixing this in P*rlScr*pt, but still can't get it to work in Python.
>
Session("key") = value is a VBScript specific thing.  Its bypassing
the default method of Session which in this case is probably Item.
I'm not sure off hand.
>Response.Redirect doesn't terminate execution of the script.  I'm getting 
>round this by throwing an exception, but is there a command that can do 
>the same job more cleanly?

Have you tried a return statement?  I'm guessing here but the asp page
is probably being executed in some kind of invisible function.

>I ran a script with an infinite loop once.  How should I have terminated 
>it (other than by proof reading my code better)?

Not sure.  The same has happened to us in vbscript and we ended up
shutting down the server.  He forgot the recordset.movenext while in a
loop processing a recordset.  Typically if you can get to the box fast
enough before the ram is swallowed up you can shutdown iis.  Otherwise
I think it was the power button because the box was totally
unresponsive.  There may be a page execution timeout that can be
specified in iis.  I don't remember off hand.

>I'm finding the, when Append-ing parameters to a stored procedure, the 
>parameter names are ignored.  Is this right?  This isn't a Python problem, 
>but I thought I'd throw it in anyway.
>
Now something that I definately know about.  I ran into this problem
last week.

Here is the relavant code.

import win32com.client
constants = win32com.client.constants  
# I just do it this way instead of a from so that its easy to reimport
in asp.


rs = win32com.client.Dispatch('ADODB.Recordset')
cmd = win32com.client.Dispatch('ADODB.Command')
cmd.ActiveConnection = ("big long connection string")
cmd.CommandText = "ExpConfig_Get" #Name of stored proc
#a tuple of parameters
params = ("ExpJobID", constants.adInteger, 4, 11),  

#Here is the line you are probably missing.
cmd.CommandType = constants.adCmdStoredProc

#Now I append the parameters...
for parm in params:
    cmd.Parameters.Append(cmd.CreateParameter(parm[0], parm[1],
constants.adParamInput, parm[2], parm[3]))

#set cursor location and run.
rs.CursorLocation = constants.adUseClient
rs.Open(cmd, CursorType = constants.adOpenForwardOnly, LockType =
constants.adLockReadOnly)


The reason that ado is ignoring your parameters is that the default
command type is adCmdText.  I guess when it is text it doesn't bother
to look for any parameters associated with the command object.  Though
it might if your sql looked like "select * from whatever where id = ?"
IIRC ? is used in the data environment designer in VB to denote a
parameter in  an sql call.

>
>Right, that'll do.  Thank you for you time and any replies.
>
>           Graham
Your welcome hope it helped,
-Sam



More information about the Python-list mailing list