Hi folks - I hope someone can help.
I have an application that lets users create, and name, new folders on the server. They can use spaces in the name (e.g. "Sports Pages").
The application stores the name with its spaces in the 'folder_name' field in a database, but creates the folder with the spaces removed("/sportspages")
To make part of the application work I need an SQL Select statement along the following lines:
Code:
"Select * from table where folder_name = sportspages"
I have tried using a function to remove the spaces from 'folder_name' - but you can't use an ASP function in a select statement.
I have battled with this for hours to no avail. Can anyone who understands these things better than me (so that'll be most of you then) offer some help?
Many thanks.
set a variable before your sql hit to equal your directory name, you can do this in your sql hit.
Code:
sTempVar = replace("Sport Pages"," ","")
"Select * from table where folder_name = '" & sTempVar & "' "
Was this answer helpful ?
Yes No
Was this answer helpful ?
Yes No
Was this answer helpful ?
Yes No
this logic is not good... in my opinion it's better to replace spaces with "_" for example so
that you can track the original name as the user gave it.
Was this answer helpful ?
Yes No
I agree, that or a period.
Was this answer helpful ?
Yes No
Thanks for all your help. I'll change the script to replace the spaces with underscores when the folders are renamed. But the replace function won't work. I just get the following error code:
Undefined function 'replace' in expression.
Quote:
| Originally Posted by mehere try this:
Code:
Select * from table where replace(folder_name, ' ', '_') = 'sportspages'
|
Was this answer helpful ?
Yes No
Quote:
| Originally Posted by gtubb Thanks for all your help. I'll change the script to replace the spaces with underscores when the folders are renamed. But the replace function won't work. I just get the following error code:
Undefined function 'replace' in expression. |
You need to do the replace when the users first define their new folder and put that name in the db table.
Was this answer helpful ?
Yes No
Jonathan
There are, as they say, more ways than one to skin a cat. I realised I already have the url of the new folder stored in the database - so I can use that as the select criteria to find the recordset.
I've wasted hours - but I would only have used them to have a life.
Thank you all for your help
Quote:
| Originally Posted by Jonathan8146 You need to do the replace when the users first define their new folder and put that name in the db table. |
Was this answer helpful ?
Yes No
Quote:
| Originally Posted by gtubb Jonathan
There are, as they say, more ways than one to skin a cat. I realised I already have the url of the new folder stored in the database - so I can use that as the select criteria to find the recordset.
I've wasted hours - but I would only have used them to have a life.
Thank you all for your help |
I'm not sure that I understand what you are saying, but I'm glad that you appear to have resolved your problem.
Was this answer helpful ?
Yes No