SQLite and Apostrophes - help

Penfound

Active Member
Licensed User
Longtime User
I have a DB of music titles which display perfectly in a scroll view.
I can change a field and UPDATE records without a problem providing they do not have an apostrophe in the title.

This code below does not replace an apostrophe. It appears that it is not even finding the apostrophe in order to replace it.

Sub UpdateRecord(CatNo As String,Value As String)
Dim cursor1 As Cursor
Dim txt As String
Dim Title,Book,Composer,Genre, Arranger As String
txt = "SELECT * FROM Music WHERE CatNo = '" & CatNo & "'"
cursor1 = SQLMusic.ExecQuery(txt)
cursor1.Position = 0
Title = cursor1.GetString("Title") 'Haven't Met You Yet
Title.Replace("'","''")
Msgbox(Title,"") 'Haven't Met You Yet instead of Haven''t Met You Yet
Book = cursor1.GetString("Book")
Composer = cursor1.GetString("Composer")
Arranger =cursor1.GetString("Arranger")
Genre = cursor1.GetString("Genre")
cursor1.Close
txt = "UPDATE Music SET CatNo = " & CatNo & ", Title = '" & Title & "', Book = '" & Value & "', Composer = '" & Composer & "',Genre = '" & Genre & "', Arranger = '" & Arranger & "' WHERE CatNo = '" & CatNo & "'"
TheMusicString = "SELECT * FROM Music WHERE Book = '" & Value & "' ORDER BY Title"
SQLMusic.ExecNonQuery(txt)
End Sub

Can anyone see what I'm doing worng please?
 
Last edited:
Top