• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

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
0
ashraf_t
Asked:
ashraf_t
  • 4
  • 4
1 Solution
 
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
 
pradapkumarCommented:
then try this

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

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ashraf_tAuthor Commented:
am i adding new character"\" to the string, If so this will be not accepted
0
 
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
 
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now