
Problem Using Apostrophy ' in Insert Statement (Urgent)
You must replace single quotes in your string with double
quotes.
The following code will solve your problem...
''''''''''''''''''''''''''''''''''''''''''''''
dim strClean as string
strClean = txtbox1.Text
strClean = Replace(strItemTxt, "'", "''")
'''''''''''''''''''''''''''''''''''''''''''''''
In your INSERT statement use strClean instead of
txtbox1.text
If you're doing lots of inserts put the code into a
Function in a module and save some time typing.
Good Luck, Dwight
Quote:
>-----Original Message-----
>Hello,
>insert into TableA values('"& txtbox1.text &"','"&
>txtbox2.text &"')
>Where
>textBox1.text = AB0001
>textBox2.text = Name's
>The above statement i am executing after getting the
above
>data from the form.
>Now, because textbox2.text has the value of Name's
>(contains the apostrophy) this insert statement generates
>error because what going at the backend is as follows:
>insert into TableA values('AB0001','Name's')
>In order to avoid this error I can do the very same thing
>by opening a Recordset, but what i need is, Is there any
>way that i can save the above data into the database with
>the help of Insert Statement.
>Well it also creates problem when I need to fetch the
>specific data from the database like "Select * From
TableA
>Where ItemName = '"& Name's &"'".
>Kindly help me to sort out this problem
>Thanks in advance
>Jawahir
>.