encode in database (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


wizard_oz -> encode in database (6/23/2008 3:03:59)

Hey, I have a problem with encoding some characters to a database. I have a simple form
<textarea name="Description" rows="7" cols="50></textarea>
and I would like to in sert it to a datebase. My problem is when someone write some charaters like ' it doen't insert to a database. The reason is at the code
conn.Execute " UPDATE TroubleShooting SET Description='" & Description& "''"
I mean I already have this symbol.
Does anyone help me?




rdouglass -> RE: encode in database (6/23/2008 8:27:48)

quote:

conn.Execute " UPDATE TroubleShooting SET Description='" & Description& "''"


Try it this way:

conn.Execute " UPDATE TroubleShooting SET Description='" & Replace(Description,"'","''") & "'"

Be careful of all those " and ' on there. The last bold section goes:

comma, double, single, double, comma, double, single, single, double

What you're doing is replacing every single apostrophe with a pair of apostrophes. That'll write a single apostrophe to the DB.

Hope it helps.




wizard_oz -> RE: encode in database (6/23/2008 8:46:58)

Thanks It is W O K I N G !!!!!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
4.492188E-02