I used NuGet Package Manager to install SQLite package in my Visual Basic 2015 Project so that i can use it in my application. The problem i am facing is that i have a sub in my application whose code is indicated below that i am using to update a table in SQLite but it does not update the values.
AddErrors is another sub that adds the errors that are captured by the try catch to the same SQLite database but different table and works fine. Can you tell me what i am doing wrong.
I have tried both the commented and the uncommitted code with both not updating the database and not throwing any errors.
Public Sub PostedLink(ByVal id As String, ByVal link As String)
Dim query As String = "UPDATE Table SET torf = 1 , link = '" & link & "' WHERE id = '" & id & "';"
Dim affectedRows As Integer = 0
Try
Using con As New SQLiteConnection(connectionString)
con.Open()
Using cmd As New SQLiteCommand(con)
cmd.CommandTimeout = 20
cmd.CommandText = query
'Dim dr As SQLiteDataReader
'dr = cmd.ExecuteReader()
affectedRows = cmd.ExecuteNonQuery()
End Using
con.Close()
End Using
Catch ex As Exception
AddErrors("Updating table", ex.ToString)
End Try
End Sub
The table i am trying to update has the following structure.
CREATE TABLE Table
(
id VARCHAR(100) PRIMARY KEY NOT NULL,
text VARCHAR(100),
link VARCHAR(254) DEFAULT "",
torf BOOLEAN NOT NULL DEFAULT 0
);