Problem in "Insert into" with Foxpro database

Hi The next code generate error in adding to foxpro database alose it works fine in Access and sql server, i discovered that the problem is in the chr(10) [chr(0) & chr(39) do the same error] , is there any help to solve this:
Notes: I need chr(10 , 0 or 39) in the output string

dim st as string
st="Test1" & chr(10) & "Test2"
S = "insert into [table1]  (Field1,Field2) Values (1 , ' " &  st  & " ')"  
DBC.Execute S

Thanx a lot
ashraf_tAsked:
Who is Participating?
 
pradapkumarCommented:
if u give chr(39){which is the equalent of single quote} will terminate the string while u insert into the sql statement. To enable that to insert the engine needed that escape character so your querry would be

insert into emp (name,age) values('Kumar\'s',19);

if u give

insert into emp (name,age) values('Kumar's',19);
this will terminate the actual string value  ^   here.
So you need to give that escape character. otherwise it will raise error message.
0
 
pradapkumarCommented:
try this use chr(13) or vbCrLf instead of chr(10)

dim st as string
st="Test1" & chr(13) & "Test2"
S = "insert into [table1]  (Field1,Field2) Values (1 , ' " &  st  & " ')"  
DBC.Execute S

All the best.
0
 
ashraf_tAuthor Commented:
infact i mustnot change any charater because the string iam saving is output from a function i designed to encrypt the string
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
pradapkumarCommented:
then try this

st="Test1" & "\" & chr(39) & "Test2"

0
 
ashraf_tAuthor Commented:
am i adding new character"\" to the string, If so this will be not accepted
0
 
ashraf_tAuthor Commented:
I tried this but it raised error also , add to this even it works i still have the problem that i added the character "\" to the encrypted string....
so i think if there are another way to add the record without using the insert into.
in fact i tried the way Addnew it works in access and sql server but it gives error in foxpro
Thanx a lot
0
 
g_johnsonCommented:
[infact i mustnot change any charater because the string iam saving is output from a function i designed to encrypt the string
]

If you designed the encryption, can you re-design the encryption so as to avoid the use of invalid characters?
0
 
ashraf_tAuthor Commented:
:) infact the easiest way is to use another database type for this table instead of foxpro (Thanx to ADO) and this what i did this night , Thanx for your help
0
 
pradapkumarCommented:
finally u conquered @};-
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.