Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2394] Problems with SQLite and Textfield

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2012-01-03T11:48:07.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
Reporterluciano
AssigneeNeeraj Gupta
Created2011-04-15T03:18:34.000+0000
Updated2017-03-09T23:14:45.000+0000

Description

I'm having trouble saving data in the database created using a textfield as follows:
cadvend.addEventListener('click', function(e)
{

var base = Titanium.Database.install('cardsdb.db','cards');
var db = Titanium.Database.open('cards'); 

db.execute('CREATE TABLE IF NOT EXISTS vendedor  (idvendedor INTEGER PRIMARY KEY AUTOINCREMENT, nome VARCHAR(30) NOT NULL, cpf VARCHAR(30) NOT NULL UNIQUE, telefone VARCHAR(30) NOT NULL)');

db.execute('INSERT INTO vendedor (nome,cpf,telefone) VALUES ("'tf1.value'","'tf2.value'","'tf3.value'")');

// main
var q = db.execute( 'SELECT * FROM vendedor' );

if( q.rowCount == 0 ){
    loadData();
}
else{
    var dataTable = [];
    var i = 0;

    while( q.isValidRow() ){
        dataTable[i] = Ti.UI.createTableViewRow({
            title : q.fieldByName( 'nome' ) + ':' + q.fieldByName( 'cpf' ) + ':' + q.fieldByName( 'telefone' )
        });

        i++;
        q.next();
    }
    q.close();

    VendWindow.add( table );
    table.setData( dataTable );
}
});
Please if anyone knows how to save using textfield help me

Comments

  1. Paul Dowsett 2012-01-02

    Propose this be closed for the following reasons: * test case not complete * user not using recommended query syntax (ie with string substitution): * it's an issue more suited to the Q&A
       db.execute('INSERT INTO vendedor (nome,cpf,telefone) VALUES ("'tf1.value'","'tf2.value'","'tf3.value'")');
       
  2. Stephen Tramer 2012-01-03

    Closing ticket so that it can be rerouted to Q&A. Ticket can be reopened if there is a valid test case demonstrating a legitimate bug in platform.
  3. Lee Morris 2017-03-09

    Closing ticket as invalid.

JSON Source