quote marks in sql statement

tremara1

Active Member
Licensed User
Hi everyone, I am trying to write a code snippet library with sqlite. My main problem is when I put an sql statement together with code sample containing quotes and apostrophes from a multiline textbox it does not treat it as text but as code. I have done this in vb6 but cant seem to get it right in b4ppc.
This is the sql statement the problem is txtAddCode.text is the code I want to store.

Addtext = "INSERT into snippet(snip,code,att) values('"
Addtext = Addtext & txtAddSnip.text
Addtext = Addtext & "','" & txtAddCode.text
Addtext = Addtext & "','" & txtAddAtt.text & "')"
If there is a solution it is probably simple.....

thanks tremara1
Australia
 

RB Smissaert

Well-Known Member
Licensed User
Look in the SQL help at AddParameter and SetParameter and use that.
With that you don't need the quotes and it will probably be faster as well.

RBS
 

Cableguy

Expert
Licensed User
You can add Quotes by using CHR(34)...
ie :
name="cableguy"
To place in a string with initial and final quotes included would be like this:
Chr(34)&"name="&Chr(34)&"cableguy"&Chr(34)

The final string would then look like this:

"name="Cableguy""
 

tremara1

Active Member
Licensed User
Thanks..........

I love this stuff......the AddParameter,SetParameter worked perfectly, I am learning heaps from you guys....much appreciated.

tremara1
Ballarat Victoria Australia
 
Top