|
-
May 6th, 2002, 10:30 AM
#1
Thread Starter
Hyperactive Member
Insert apostrophe into SQL server
How do I insert an apostrophe into my database
ex:
Code:
INSERT INTO BLAH(BlaBla) VALUES('Boîte d'engrenage')
this will cause an error because of the quote inside the quotes
-
May 6th, 2002, 11:07 AM
#2
Don't use SQL. Use VB's .AddNew/.Update
VB doesn't care about apostropes at all.
-
May 6th, 2002, 11:47 AM
#3
Thread Starter
Hyperactive Member
Ok but if I use the addnew would the "SELECT @@Identity" work to get the PK of the record just inserted
-
May 6th, 2002, 11:51 AM
#4
VB's method requires using a pre-built recordset. I just generally do a SELECT * and use that.
-
May 6th, 2002, 11:58 AM
#5
Thread Starter
Hyperactive Member
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.
-
May 6th, 2002, 12:12 PM
#6
Thread Starter
Hyperactive Member
I was thinking, isn't it less effective to open a recordset just for inserting a row?
-
May 6th, 2002, 12:18 PM
#7
Originally posted by maxl
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.
Effective, or ineffective, for me is not even a remote concern. It is the easiest.
-
May 6th, 2002, 12:24 PM
#8
Black Cat
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.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
May 6th, 2002, 12:28 PM
#9
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.
-
May 6th, 2002, 12:36 PM
#10
Thread Starter
Hyperactive Member
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: becomes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|