This topic is locked

SESSION Variable

3/19/2008 1:19:18 PM
ASPRunnerPro General questions
A
alx10 author

Hi,
I have a problem using SESSION variables.
Tables:

Fac

--IdFac [Primary Key]

--CustID

FacDetail

--IdFac [Foreign Key with Fac]

PriceByCust

--CustId

--Price
I use a master detail relation between them, and i show the master info in the detail page.
On the ListOnLoad Event of the detail page i use the following code:

set rstmp = Server.CreateObject("ADODB.Recordset")

rstmp.open "select * from Fac where IdFac = " & SESSION(strTableName & "_masterkey1"), dbConnection
Session("MField2") = rstmp("CustId")
rstmp.close : set rstmp = nothing


At the detail page, a Lookup wizard with the table PriceByCust use the SESSION("MField2") in the Where as follow: [" CustId = " & Session("MField2")]
The problem is that at run time it displays:
Error Type:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)

[Microsoft][ODBC Microsoft Access Driver] Extra ) in query expression '[IdProducto] = 8 and ( CustId = )'.

/Project2/FacDetail_list.asp, line 692

The way i found to fix it is to create a new record in the Fac table and clic on FacDetail link to see an empty detail, and then it works fine.
Any idea of what is happening?
Many thanks

J
Jane 3/21/2008

Hi,
try to use this code:

set rstmp = Server.CreateObject("ADODB.Recordset")

rstmp.open "select * from Fac where IdFac = " & SESSION(strTableName & "_masterkey1"), dbConnection
if rstmp("CustId")=0 or isnull(rstmp("CustId")) then

Session("MField2") = 0

else

Session("MField2") = rstmp("CustId")

end if
rstmp.close : set rstmp = nothing

A
alx10 author 4/5/2008

Hi,

try to use this code:


Thaks a lot for your help, but the error remains <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=27645&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' /> any other idea?
In the mean time what i do is paste this code direct to the _list Page and it works but i dont think is the right way, because i see the include with the onLoad() Sub at the top.

J
Jane 4/7/2008

Hi,
it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.