This topic is locked

displaying Master table value on the child table

9/27/2013 2:54:47 AM
ASPRunnerPro General questions
A
adnankmk author

I want to use the CNIC(numeric) field of master table on the add page of child table page. I use this function in before Process record values.
sql="SELECT CNIC_NO from LGCD_EMPLOYEES WHERE CNIC_NO=" & session("CNIC_NO")

rs=CustomQuery(sql)

values("CNIC_NO")=rs("CNIC_NO")
When I access the child table record I use the following error.
Microsoft OLE DB Provider for SQL Server error '80040e07'
Error converting data type varchar to numeric.
/hrm/include/dal.asp, line 255

How I should resolve this error.

admin 9/27/2013

If CNIC_NO is a text field your SQL query should look like this:

sql="SELECT CNIC_NO from LGCD_EMPLOYEES WHERE CNIC_NO='" & session("CNIC_NO") & "'"
A
adnankmk author 10/2/2013



If CNIC_NO is a text field your SQL query should look like this:

sql="SELECT CNIC_NO from LGCD_EMPLOYEES WHERE CNIC_NO='" & session("CNIC_NO") & "'"



Thanks for replying.
My CNIC_NO field data type in both tables is numeric. I used a button in the view page of the master table to access the add page of child table. I want to display the view page CNIC_NO on the add page of the child page.
If I give fixed value of CNIC it works perfectly. the code is given as under
sql="SELECT CNIC_NO from LGCD_EMPLOYEES WHERE CNIC_NO= '" & 2345678912345 & "'"
But if I use session variable it gives the error. the code is given as under
sql="SELECT CNIC_NO from LGCD_EMPLOYEES WHERE CNIC_NO= '"& session("CNIC_NO") & "'"

admin 10/2/2013

I guess you need to make sure that session("CNIC_NO") session variable is populated. It looks like this variable is empty.

A
adnankmk author 10/21/2013

Thanks for replying. How should I populate the value to the session variable. Can you help me for solving this problem

admin 10/21/2013

Before using any session variable you need to assign some value to this variable. Where this it needs to bedone and how - greatly depends on details of your application.
Here is the sample syntax:

session("CNIC_NO")="Some value"