iosswiftsqlitesqlitemanager

how to update Table using SqliteManager in swift


I am using SqliteManager to add data in database.

I have to update a table with the query below but it doesn't updating table data.

SQLiteManager.sharedInstance().executeQuery("UPDATE Invoice SET is_void = '1',void_comment ='\(txtComment.text)',void_date = '\(currentDateTime)' WHERE invoice_id = '\(inVoiceNumber)'")

Can someone please tell me what is wrong with this query or how can I check if the data is updated?

Structure of table Invoice

CREATE TABLE [Invoice]
(
   [is_void] INT,
   [void_comment] NVARCHAR(500),
   [void_date] NVARCHAR(50),
   [invoice_id] BIGINT,
)

Solution

  • For dynamic inVoiceNumber, Just pass like this no nee to add single quote.

    var inVoiceNumber = Int(arrSales[tags].valueForKey("invoice_id") as! String)
    SQLiteManager.sharedInstance().executeQuery("UPDATE Invoice SET is_void = 1,void_comment ='\(txtComment.text)',void_date = '\(currentDateTime)' WHERE invoice_id = \(inVoiceNumber)")