Insert Apostrophe into Database

Visual Basic 6

Some error came bugging recently in the Visual Basic 6 program (yes, it is semi ancient but some companies are still using it). After deployment of program, there was an error that popped up recently.

It haven’t popped up before due as there was no occurrence of it before.

error syntax

Based upon the error popping up, what seems to be the problem? After debugging it looks like due to the name has a special character that usually affects a lot of other programming languages out there. It has an apostrophe in the name

How to solve?
If you are using pure SQL, do make sure to put another extra apostrophe ( ‘ ) in the syntax.

Sample:

"insert into client name values ('Dan''iel')"

This will solve your small bug with apostrophe in the name.

Leave a Reply