Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trim() used on a recordset

Status
Not open for further replies.

RoKKos

Programmer
Feb 3, 2003
50
SE
Hi

I am trying to use the trim() function directly on a recordsetcall.. this is my code:

Code:
response.write(trim(objRecSet("personid")))

have also tired

Code:
response.write(objRecSet(trim("personid")))

neather of the codexamples above works BUT
the code below works

Code:
dim personid
personid = objRecSet("personid")
response.write(trim(personid))

is there anyway I can use the trimfunction directly on the recordset, as shown in the fist two examples??
 
hehe.. well one would think so.
But the databas (access) I´m pulling my records from sometimes has whaitespaces in the records, and it is rely enoying.
 
Well 'whitespace' isnt blank so one way would be to use a regular expression to remove them, which would be longer than just using the trim function once you've put the field into a variable

 
I have no problem using the following code to trim spaces off a recordset field:

Code:
Response.Write Trim(rs("col1"))

Do you get an error or is it just not working as you expect? --James
 
Try doing a cStr first to force it to a string datatype. It may be doing that when it gets assigned to the variable which is whatis allowing you to trim it after it has been assigned to a variable:
Code:
response.write(objRecSet(trim(cStr("personid"))))

That may be enough to force it to work correctly.

As a sidenote, char(n) fields in SQL Server pad all entries with whitespace to length n. So the only entries in a field like that that wouldn't have padding would be the ones that fit exactly...

-Tarwn
01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Well.. I do not know Y but I got

Code:
response.write(trim(objRecSet("personid")))

to work now, have no idé way it did´t work befor. Thanx for all your input, forcing a cStr helped me solve an other problem :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top