We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,124 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

problem regarding insert into statement

hello experts . . .
i am using following code:-
con.Execute "insert into tbl values('" & Text1.Text & "','" & Text2.Text & "') ", adCmdText
i am trying to insert data using above statement and its working well but an error occures when i input data (contaning the symbol ' )

for example when i input qwe'r it will give an error

So Any Solution to do so . . .

2
Contributors
3
Replies
3 Hours
Discussion Span
3 Months Ago
Last Updated
4
Views
Question
Answered
rishif2
Junior Poster
156 posts since Dec 2012
Reputation Points: 54
Solved Threads: 32
Skill Endorsements: 3

The following should do the trick -

con.Execute "insert into tbl values('" & Replace$(Text1.Text, "'", "''") & "','" & Text2.Text & "') ", adCmdText

''Assuming that Text1 will return the apostrophe character...

''Note the double '' inside there to still make the sql work.
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20

thanx , its working . . .

rishif2
Junior Poster
156 posts since Dec 2012
Reputation Points: 54
Solved Threads: 32
Skill Endorsements: 3
Question Answered as of 3 Months Ago by AndreRet

Only a pleasure. Happy coding.

AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.1953 seconds using 2.67MB