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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing a paragraph to database

Status
Not open for further replies.

KSiva

Programmer
Feb 18, 2002
63
0
0
AU
Hi all,

I am trying to store a paragraph (which may contain any character like , ' ` ) ( ... I hope you know what I mean! But problem would arise when I store these into database. How do I get red of the special charcters and retrive the same character and display same as the user entered! Is there any function to do that! Sivakumar Kandaraj
web system programmer
Melbourne
 
Just make 2 functions and replace chr with double of that chr, using the replace function

Function IncodeDbText(sometext)

'incode text
' comma = commacomma

TempTxt = Replace(sometext, chr(34), chr(34) & chr(34))
'...
End function


Function DecodeDbText(sometext)

'put it back to normal
'commacomma = comma

TempTxt = Replace(sometext,chr(34) & chr(34, chr(34))

'...
End function

And so on..
www.vzio.com
star.gif
if I helped. [wink]
 
snowboardr,

sorry for late reply.

like you said, i change this word : "siva,snowboardr" to

"siva,,snowboardr" ...

But when you store this string to a database, would not that cause problems? So as with ' " ) ( etc characters?

Please give me an Idea!

Been to your website vzio.com! Pretty good stuff mate!

Siva Sivakumar Kandaraj
web system programmer
Melbourne
 
You should make a replace function for each character that will conflict with the database.

Jason www.vzio.com
ASP WEB DEVELOPMENT



 
Yes ... I understand that! But like you said replace chr with double the chr... would that be a valid way of doing it?

Would not that cause problem? I am sorry if I am asking dump questions! But i want to be very clear before I sit and write the code!

Siva Sivakumar Kandaraj
web system programmer
Melbourne
 
Hi

Like snowboardr said you can use the replace statement, but you don't need to use chr function. You can use the replace statement like this

strText = replace(strText,"'", "''")

this same code is common practice in VB with ADO connections.
 
The replace function is very valuable, and there is no such thing as a dumb question we have heard every type of question here.

www.vzio.com
ASP WEB DEVELOPMENT



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top