This topic is locked

Event Question in version 4.1 build 130

10/23/2006 11:47:58 AM
ASPRunnerPro General questions
J
jlemecthomas author

In version 4.0 I used the following codes to store a few session variables and it worked fine:
Sub AddOnLoad()

'

' put your custom code here

'(the data is collected from a msSql server)
str = "select * from [hcdfuser].[Eleves] where AutoID=" & GetRequestForm("masterkey")

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
Session("EcoleID") = rsTemp("EcoleID")

Session("ParentID") = rsTemp("ParentID")

Session("EleveID") = rsTemp("EleveID")

Session("Palmares")= rsTemp("Palmares")
End Sub
But the same codes do not work in version 4.1 (138).
I've noticed a couple of other approaches in terms of the variable name that reference the master key and tried them:
GetRequestForm(strTableName &"_masterkey1")

strMasterKey
but error still occurs
The error happens at the query level, not the default level but the variable GetRequestForm(strTableName &"_masterkey1") which is entered automatically does not return the default value on the Add page.
Here is the error generated when the add page is called:
Technical information

Error number -2147217900

Error description [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '='.

URL /fpdb/asprunner/exode/Scores_add.asp

Solution There are the bug in the custom query.
I recommend you to build your project in the Debug mode. Check off "Debug mode" on the "Output Directory" tab and rebuild your project.
(If there is a check box to select "Debug mode" in the Output Directory, I am not seeing it.)
Any idea on what the source of the problem may be?
Thanks you.

Sergey Kornilov admin 10/23/2006

In version 4.1 you need to use the following:

Sub AddOnLoad()

'

' put your custom code here

'(the data is collected from a msSql server)
str = "select * from [hcdfuser].[Eleves] where AutoID=" & prepare_for_db("AutoID",SESSION(strTableName & "_masterkey1"),"","")

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
Session("EcoleID") = rsTemp("EcoleID")

Session("ParentID") = rsTemp("ParentID")

Session("EleveID") = rsTemp("EleveID")

Session("Palmares")= rsTemp("Palmares")
End Sub

J
jlemecthomas author 10/25/2006

I am using these modified codes for passing parameters from a master to a detail table in Version 4.1:
str = "select * from [hcdfuser].[contributors] where ID=" & prepare_for_db("ID",SESSION(strTableName & "_masterkey1"),"","")

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
Session("Designation") = rsTemp("Designation")
but when I click on ADD New Record I get the following error:
Technical information

Error number -2147217900

Error description [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'UWA00834'.

URL /fpdb/asprunner/hcdf/Contributions_add.asp

Solution
where 'UWA00834' is the right value from the ID field.
I do not seem to be able to identify the cause.
Thanks
Jean

J
jlemecthomas author 10/25/2006

Ok... I found the solution... the Masterkey being passed is of type String and I needed to add quotation marks before and after. The following change worked fine:
str = "select * from [hcdfuser].[contributors] where ID='" & prepare_for_db("ID",SESSION(strTableName & "_masterkey1"),"","") & "'"
Jean