Discussion Locked

insert string into db table using sql

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

statustx="i'll do it"
strSQL = "INSERT INTO otherstatus (sendby,sendto,message) "
strSQL=strSQL & "SELECT "
strSQL=strSQL & "'" & empl & "' as text1,"
strSQL=strSQL & "'" & recieverid & "' as text2,"
strSQL=strSQL & "'" & statustx & "' as text3 "

the problem with ' in string statustx,it closes the singlr quote in sql statement..how should i do it?

8 replies

by ben.boyle

Can't tell what languiage you're using but there's usually an escape character that helps handle this sort of situation.

Best guess is to try putting a backslash (\) before the single quote ("i\'ll do it") or maybe using two single quote marks ("i''ll do it").

Hope this helps....

by adouani

thank you for trying to help i fixed it by
statustx=replace(statustx,"'","''")
before sql statement

by wj.van_bergen

You should add an extra single quote to the single quote, like:
statustx="i''ll do it"
that should do the trick: a small function could do this for you, so you get something like this:
statustx=extraquote("i'll do it")

This discussion is closed to new replies.