|
-
Apr 28th, 2001, 11:44 PM
#1
Thread Starter
New Member
SQL Update on data with an apostrophe in it
I am trying to update an existing database record. The value I am trying to put in the [Title] field of the database has an apostrophe in it. I cannot get the syntax of my SQL update query coded right so the value updates the way it should.
This is the SQL
strSQL = "UPDATE Video " & _
"SET [Title] = '" & txtTitle.Text & "', " & _
"[Category] = '" & cboCategory.Text & "', " & _
"[Studio ID] = '" & cboStudioID.Text & "', " & _
"[Length] = " & intlength & _
" WHERE [Movie Number] = '" & mskMovieNumber.Text & "'"
For example when txtTitle.Text is equal to My Mother's Diary, I get a syntax error.
I tried to change the SQL for the title part to:
"SET [Title] = "" & txtTitle.Text & "", " & _
which updated the Title on my record to & txtTitle.Text &
I also tried this:
"SET [Title] = ''" & txtTitle.Text & "'', " & _
which gave my another syntax error.
I am using VB 6.0 and a Microsoft Access 97 database file.
Any help you can give me would be most appreciated!
Deb
-
Apr 29th, 2001, 06:56 AM
#2
Hyperactive Member
Deb
here's a function i've used in .ASP files before but have never tried it in VB:
Code:
Replace(txtTitle.Text, "'", "''")
I usually set a variable = to the above statement then put the variable in my SQL statement(don't know if that makes any difference), if that doesn't work look for something along those lines, i don't think the answer is changing the SQL statement.
VB6.0 SP4
Windows 2000
I'm thinking of a number between
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
|