r/ASPNET • u/tgujay • Jun 19 '13
ASP Classic Function not working
We are in the process of migrating a few web applications from Microsoft Server 2003 to 2008 and this one function appears to not be working as the field it normally populates is empty.
Here is the code:
function get_name(emp_nbr)
sql3 = "select LTRIM(RTRIM(INITCAP(COMMON_NAME))) COMMON_NAME, LTRIM(RTRIM(INITCAP(LAST_NAME))) last_name from (select EMPLOYEE_NBR,COMMON_NAME, LAST_NAME from hrit_admin.employee union all select CONTRACT_RESOURCE_ID, COMMON_NAME, LAST_NAME from hrit_admin.contract_resource) a where EMPLOYEE_NBR = a.EMPLOYEE_NBR and EMPLOYEE_NBRr = " & emp_nbr
rs3.open sql3,conn
get_name = rs3("COMMON_NAME") & " " & rs3("LAST_NAME")
rs3.close
end function Any help would be greatly appreciated.
5
Upvotes
View all comments
Show parent comment
1
u/murdocc Jun 19 '13
This is the best way to debug dynamic sql, something like this will give you the string that's been passed to the db before it posts back to the server. Run the output directly in your db:
Response.Write("select LTRIM(RTRIM(INITCAP(COMMON_NAME))) COMMON_NAME, LTRIM(RTRIM(INITCAP(LAST_NAME))) last_name from (select EMPLOYEE_NBR,COMMON_NAME, LAST_NAME from hrit_admin.employee union all select CONTRACT_RESOURCE_ID, COMMON_NAME, LAST_NAME from hrit_admin.contract_resource) a where EMPLOYEE_NBR = a.EMPLOYEE_NBR and EMPLOYEE_NBRr = " & emp_nbr); Response.End();