How do I insert an apostrophe into my database
ex:this will cause an error because of the quote inside the quotesCode:INSERT INTO BLAH(BlaBla) VALUES('Boîte d'engrenage')
Printable View
How do I insert an apostrophe into my database
ex:this will cause an error because of the quote inside the quotesCode:INSERT INTO BLAH(BlaBla) VALUES('Boîte d'engrenage')
Don't use SQL. Use VB's .AddNew/.Update
VB doesn't care about apostropes at all. :)
Ok but if I use the addnew would the "SELECT @@Identity" work to get the PK of the record just inserted
VB's method requires using a pre-built recordset. I just generally do a SELECT * and use that.
Yeah i forgot that I dont' need the select @@identity because I have a recordset so has soon has i update i can have access to the pk.
I was thinking, isn't it less effective to open a recordset just for inserting a row?
I won't argue with that, but, in my opinion, it beats the hell out of dancing around the SQL barn over inserting something with an apostrophe.Quote:
Originally posted by maxl
I was thinking, isn't it less effective to open a recordset just for inserting a row?
Effective, or ineffective, for me is not even a remote concern. It is the easiest.
This is MS SQL Server?
Write a Stored Procedure to do the Insert and use the ADO Command object to execute it - safer and faster.
JoshT makes a good point. Actually, I do have a stored procedure that does this for me when I do inserts into Oracle.
I made the assumption (perhaps incorrectly) that maxl was talking about an Access database.
I am actually using SQL Server 2000 but I know nothing about stored procedure and by the way i found out how to insert an apostrophe you just double it ex:becomesCode:Boîte d'engrenage
Code:Boîte d''engrenage