This topic is locked

Custom Query Error

7/9/2013 5:39:17 AM
ASPRunnerPro General questions
A
adnankmk author

I have used this query to display the CNIC_NO of the employee on the add page of child table.
CNIC_NO (numeric) declared in both tables.
I used this query on add page before process record event.
sql="SELECT CNIC_NO from LGCD_EMPLOYEES WHERE CNIC_NO= '" & session("CNIC_NO") & "'"

rs=CustomQuery(sql)
values("CNIC_NO")=rs("CNIC_NO")
When I open the page it gives an 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 can i fix this error

Sergey Kornilov admin 7/9/2013

If CNIC_NO is a numeric field you do not need single quotes in your query.

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

rs=CustomQuery(sql)

values("CNIC_NO")=rs("CNIC_NO")


Besides that this query doesn't make any sense. You are selecting exactly the same value you already have in your session variable.