简体   繁体   English

iPhone / Objective-C上的SQLite3 INSERT,未添加值

[英]SQLite3 INSERT on iphone / objective-c, values not added

need help from some gurus here, I have a database which I have moved to the documents directory. 需要一些专家的帮助,我有一个数据库,该数据库已移至documents目录。 For one procedure, I check if a table 'PASS' exists, if it does I delete & recreate it (just quicker). 对于一个过程,我检查表'PASS'是否存在,是否删除并重新创建它(更快)。 then I start reading data from another table 'EN', at the end of the calculation I attempt to insert values (ints, chars from the 'EN' table, floats) from both the 'EN' table and my own calcs 然后我开始从另一个表“ EN”中读取数据,在计算结束时,我尝试从“ EN”表和我自己的计算中插入值(int,“ EN”表中的字符,浮点数)

the procedure loops a couple hundred times and passes through the sqlite3_exec statement without errors. 该过程循环了数百次,并通过sqlite3_exec语句而没有错误。

But when I go to check the table it's empty (used sqlite manager addon for firefox) 但是,当我去检查表时,它是空的(Firefox使用了sqlite管理器插件)

the actual code is below, if anyone could spot the problem I'd be in great debt 实际的代码在下面,如果有人可以发现问题,我将背负沉重的债务

thanks 谢谢

sqlite3 *dbCon;                      
sqlite3_open([self.dblocation UTF8String], &dbCon); // open    

NSString *insert=[NSString stringWithFormat:@"INSERT INTO PASS VALUES('%d','%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f,%f');",
    sqlite3_column_int(selectstmt, 0), //id
    sqlite3_column_text(selectstmt, 1), // type 
    sqlite3_column_text(selectstmt, 2), // designation
    sqlite3_column_double(selectstmt, 4), // weight
    sqlite3_column_double(selectstmt, 5), //area
    d, // depth
    sqlite3_column_double(selectstmt, 28), // ix
    sqlite3_column_double(selectstmt, 30),
    cb,
    mmax,
    smax,
    stress,
    fb,
    shear,
    0.4*1000*yield,
    def,
    span/240.,
    span/360.
    ];

    sqlite3_exec(dbCon, [insert UTF8String],NULL,NULL,nil); // borrada
    sqlite3_close(dbCon);

NEVERMIIND, 永远不要

at the end of the NSString I have '%f,%f' ~~> '%f','%f' fixes it 在NSString的末尾我有'%f,%f'~~>'%f','%f'修复了它

thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM