|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How do i handle special characters?
Through javascript i am forming a dynamic sql based on some selection criteria entered by the user. If i am trying to have an alias with '&', then on executing this through an ADODB object , the statement fails and i get an error as "from keyword not found"
For ex: If i have a SQL as select emp_name as "Emp&Mgr" from emp; on executing this i get the above mentioned error. But SQL's with other special characters do work. For ex: select emp_name as "Emp,Mgr" from emp; select emp_name as "Emp/Mgr" from emp; select emp_name as "Emp*Mgr" from emp; How do i solve this problem. Thanks in advance. |
|
#2
|
||||
|
||||
|
I don't quite understand the Javascript reference, but I think your problem can be solved by escaping the "&" character with a "\" (backslash) in front of it: "\&"
You might also try enclosing the new field name alias in square brackets [] which sometimes does the trick. It would seem to depend on the ASP code, but it is tough to say without seeing it. One thing which helps to understand in troubleshooting is to Response.Write the SQL statement to see what the DB is actually receiving, which sometimes makes the solution more easily identifieable. Last edited by OldJacques : September 5th, 2003 at 03:47 AM. |
|
#3
|
|||
|
|||
|
How do i handle special characters
Hi,
Your Q: Problem in executing queries in the ex given. For ex: select emp_name as "Emp,Mgr" from emp; select emp_name as "Emp/Mgr" from emp. Possible solution: a) select emp_name as 'Emp,Mgr' from emp -> use single quotes or b) select emp_name as [Emp,Mgr] from emp.-> use square bracket |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > How do i handle special characters? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|