Forums

ASP

This topic is locked

Removing characters

Posted 02 Nov 2004 00:32:55
1
has voted
02 Nov 2004 00:32:55 Simon Bloodworth posted:
I have a site which uses an already existing access database for its content. the problem with the database is that all the pictures are resident on the the local machine and thus the route to the file in access database includes the drive location like "c:"

Now when using this database online it looks for a c drive when trying to display the pictures. Is the any variant of the TRIM function that will allow me to remove the first 2 characters of the path that is sent back from the database, else every row in the database has to be manually changed, and theres alot of rows!

any help appreciated.

Regards

Simon

Replies

Replied 02 Nov 2004 13:42:06
02 Nov 2004 13:42:06 Rene Bandsma replied:
Use the Left() function.
Replied 02 Nov 2004 20:05:14
02 Nov 2004 20:05:14 Simon Bloodworth replied:
this only removes spaces though. is there way of getting it to remove the first 2 letters?
Replied 02 Nov 2004 20:43:13
02 Nov 2004 20:43:13 Rene Bandsma replied:
Well... what is the reason for NOT using the TRIM fuction?

<pre id=code><font face=courier size=2 id=code>
&lt;%=Mid("xxRemove XX",3,1000)%&gt;
</font id=code></pre id=code>

Result: Remove XX

Altough the 1000 in the code is not very clean it will do the trick. You could also count your string length and put everything in a DIM, then the '1000' is not needed anymore.
Replied 02 Nov 2004 20:58:49
02 Nov 2004 20:58:49 Simon Bloodworth replied:
can i get the trim function to remove the first 2 letters?
Replied 02 Nov 2004 21:18:29
02 Nov 2004 21:18:29 Simon Bloodworth replied:
this is what is in the database

Y:/pictures/picture1.jpg

When this link is used from the database for a dynamic image it looks for a Y drive so somehow i need to trim the Y and : from the string so that the link that is returned is /pictures/picture1.jpg.

how can i acheive this?

HELP!!!
Replied 03 Nov 2004 00:05:36
03 Nov 2004 00:05:36 Rene Bandsma replied:
As I said in the previous post: YES!

<pre id=code><font face=courier size=2 id=code>
&lt;%=Mid("Y:/pictures/picture1.jpg",3,1000)%&gt;
</font id=code></pre id=code>
Replied 03 Nov 2004 00:12:50
03 Nov 2004 00:12:50 Simon Bloodworth replied:
many thanks for your help but how would i use this - where does the request from the database go
&lt;%=(Recordset1.Fields.Item("Photo1Path".Value)%&gt;

cheers
Replied 03 Nov 2004 20:30:40
03 Nov 2004 20:30:40 Simon Bloodworth replied:
sorry to be a nag - but i do now understand what you are saying, but the actual string comes from a row in my database,

im using mid(&lt;%=(Recordset1.Fields.Item("Photo1Path".Value)%&gt;,3,1000)

but it doesnt work.

any suggestions please, and i do appreciate your help.
Replied 15 Nov 2004 17:14:30
15 Nov 2004 17:14:30 myke black replied:
Nearly there, you should just use

<pre id=code><font face=courier size=2 id=code>&lt;%=mid(Recordset1.Fields.Item("Photo1Path".Value),3,1000) ) %&gt;</font id=code></pre id=code>

or more neatly:

<pre id=code><font face=courier size=2 id=code>&lt;%

dim strImage as String
strImage = Recordset1.Fields.Item("Photo1Path".Value
if len(strImage) &gt; 2 then
response.write(mid(strImage,3,len(strImage)))
end if

%&gt;</font id=code></pre id=code>


which should do the trick



Edited by - mykeblack on 15 Nov 2004 17:18:06
Replied 15 Nov 2004 19:34:45
15 Nov 2004 19:34:45 Simon Bloodworth replied:
had made a fix to this problem but it was very long winded and innvolved alot of code, but i was not aware that i could just add this to the recordset value.

many thanks for your help

Reply to this topic