Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
simflex
Constraint Violating Yak Guru
327 Posts |
Posted - 2007-08-03 : 10:25:10
|
Greetings:I have 2 pages, listings.asp which displays a summary of records, and a deleteFile.asp which deletes files from a directory on our server.A value is passed from the listings.asp page to the deleteFile.asp page.That value is similar to this:path = fpath = curTitle & "/" & fnamewhich looks like this:Path = ProgramFiles\EnglishFolder\FilenameThen I use sql string like this[html]SQL = "DELETE FROM Uploads WHERE ProgramTitle & '/' & Filename = '" & virtualpath & "'"[/html]It looks like this:[html]SQL = "DELETE FROM Uploads WHERE curTitle/fileame = 'EnglishFolder/english101'[/html]But because I *don't* have 'EnglishFolder/english101' as a fieldname on the database, it isn't working.Is there a way for me to strip [COLOR="Red"]'EnglishFolder/'[/COLOR] part of the code off from the WHERE clause so the code reads:DELETE FROM Uploads WHERE fileame = '[COLOR="Red"]english101'[/COLOR]??I hope this question is clear.Thanks in advance |
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-08-03 : 11:32:31
|
If you just want >>>DELETE FROM Uploads WHERE fileame = '[COLOR="Red"]english101'[/COLOR]From>>>SQL = "DELETE FROM Uploads WHERE ProgramTitle & '/' & Filename = '" & virtualpath & "'"why do you even concatenate ProgramTitle & '/' & Filename ? Why not just use "DELETE ... WHERE Filename = ...You can either do it in T-SQL or in ASP. Check out REPLACE function. In T-SQL you can use CHARINDEX to look for "/" and use SUBSTRING to get rid of the "EnglishFolder/".Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
|
|
simflex
Constraint Violating Yak Guru
327 Posts |
Posted - 2007-08-03 : 11:56:32
|
hi Dinakar and thanks for your prompt response.why do you even concatenate ProgramTitle & '/' & Filename I did that because the file is on the folder called ProgramTitle and all files associated with are on that folder.So, to delete the file on a particular folder, you have to use the full path, otherwise, I was getting "file not found" error message.So, concatenating ProgramTitle with Filename solved that problem.Unfortunately, as I stated, that same logic doesn't work as far as deleting the same file from the database.I am not using SQL Server. I am using MS Access database.Do you mind giving me an example of accomplishing this with the Replace function, please?For instance,SQL = "DELETE FROM Uploads WHERE Filename = '" & Replace(virtualpath, ,"ProgramTitle/"," ") & "' "doesn't work. |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-08-03 : 12:00:13
|
I dont use Access or ASP but I am sure there are similar string functions that you can use to manipulate your values.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
|
|
|
|
|
|
|