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.

 All Forums
 Other Forums
 MS Access
 Inserting Textarea with punctuations into access table through asp...

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-18 : 09:57:02
rUI writes "HELP! I know the answer is probably so simple I will kick myself. I am build an INSERT statement to insert a record into an access database, however, one of the fields, the value contains punctuation such as single and double quotes. I need to be able to store this so that I may display again later on.

Any idea?

Thank You"

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-03-18 : 17:33:40
You just need to replace a single quote with two.

x = "I've got a quote"
y = replace(x,"'","''")
sSQL = "insert into TABLENAME (words)"
sSQL = sSQL & " values ('" & y & "')"

rst.Open sSQL, cnDB
etc etc

SQL will interpret '' as ' so when you recall it, it will be correct. I usually create a function through which I pass every value, before building SQL statements - replace single quotes, substitute "" for "NULL" etc etc

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page
   

- Advertisement -