mercredi 1 juillet 2015

I am getting wrong value from sqlite table in swift

I am getting wrong value from sqlite table. this is my code

code :

    var arrtribute_Mast_List : NSMutableArray = []
    var querySQL = String(format:"SELECT * FROM %@ ORDER BY %@", TABLE_ATTRIBUTE_MASTER, ATTRIBUTE_MASTER_ATTR_ID)
    var statement:COpaquePointer = nil
    //querySQL =   querySQL.String(NSUTF8StringEncoding, allowLossyConversion: false)

    if (sqlite3_prepare_v2(database, querySQL, -1, &statement, nil) == SQLITE_OK) {
        while(sqlite3_step(statement) == SQLITE_ROW) {
            let name  = sqlite3_column_text(statement, 2)
            let attributeName = String.fromCString(UnsafePointer<CChar>(name))
            println("Attribute value = \(attributeName)")
         }
        sqlite3_finalize(statement);

    }

I am getting output:

   Attribute value = Optional("Shamitabh")

Need Output :

   Attribute value = "Shamitabh"

Aucun commentaire:

Enregistrer un commentaire