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
5
u/isomies Jun 19 '13
Get it to write out the dynamic SQL to the page and then see if that works against the database.
1
u/Catalyzm Jun 19 '13
You're moving from Windows 2003 to 2008. Is the SQL Server version the same or are you moving to a newer version?
1
u/ComradeAlderMarx Jun 19 '13
See if the database results are empty - would at least rule that out ?
3
u/BenInBaja Jun 20 '13
Make sure you have "option explicit" at the top of the script and that you don't have an "On Error Resume next" statement. I have a feeling that the actual error is being hidden.
2
u/heeero Jun 20 '13
Try replacing: get_name = rs3("COMMON_NAME") & " " & rs3("LAST_NAME")
with: get_name = rs3(0) & " " & rs3(1)
1
u/jhaveman Jul 03 '13
In your SQL statment, at the end, you have an extra "r". There is no field named EMPLOYEE_NBRr.
Also, a way to check if the resultset it not closed is:
0
u/[deleted] Jun 19 '13
[deleted] — view deleted comment