Access Database question

  • Thread starter Thread starter Eddie
  • Start date Start date
E

Eddie

Hi,

I working with vb.net and a Microsoft Access Database. I
am tring to input a single quote ' into a table (query
below). However, I am recieving an error. How would I go
about performing such a task?

INSERT INTO list (name, value) VALUES ('Sam', 'Sam's Car')

Thanks in advance.

Eddie
 
In addition to Miha's response, you may want to try

INSERT INTO list(name, value) VALUES (?, ?)

cmd.Parameters.Add("Sam")
cmd.Parameters.Add("Sam's")

HTH,

Bill
 
Both Miha and Ryan have given you correct answers, but you should
strongly consider Ryan's solution of using parameterized SQL
statements, since when you do that ADO.NET will take care of the
embedded single quote for you, making your SQL statements much more
flexible.

Study the section of the help files dealing with Parameterized Queries
and you will see what Ryan means.


In addition to Miha's response, you may want to try

INSERT INTO list(name, value) VALUES (?, ?)

cmd.Parameters.Add("Sam")
cmd.Parameters.Add("Sam's")

HTH,

Bill

Otis Mukinfus
http://www.otismukinfus.com
 
The "best practice" is to use Command objects to manage this detail for you.

--
____________________________________
Bill Vaughn
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
This should do it....
INSERT INTO list VALUES("Sam", "Sam's Car")

query table must have only 2 fields
 
Back
Top