iphone - sqlite insert putting values into wrong fields -
i'm trying insert this
- (void)insertblogstory:(nsstring *)storytitle link:(nsstring *)link storydescription:(nsstring *)storydescription storyhtml:(nsstring *)storyhtml pubdate:(nsstring *)pubdate blog:(nsstring *)blog { nslog(@"storytitle %@",storytitle); nslog(@"link %@",link); nslog(@"storydescription %@",storydescription); nslog(@"storyhtml %@",storyhtml); nslog(@"pubdate %@",pubdate); nslog(@"blog %@",blog); if(addstmt == nil) { const char *sql = "insert contents (storytitle, link, storydescription, storyhtml, pubdate, blog, read) values (?, ?, ?, ?, ?, ?, ?)"; if(sqlite3_prepare_v2(_database, sql, -1, &addstmt, null) != sqlite_ok) nsassert1(0, @"error while creating add statement. '%s'", sqlite3_errmsg(_database)); } sqlite3_bind_text(addstmt, 1, [storytitle utf8string], -1, sqlite_transient); sqlite3_bind_text(addstmt, 2, [link utf8string], -1, sqlite_transient); sqlite3_bind_text(addstmt, 3, [storydescription utf8string], -1, sqlite_transient); sqlite3_bind_text(addstmt, 4, [storyhtml utf8string], -1, sqlite_transient); sqlite3_bind_text(addstmt, 5, [pubdate utf8string], -1, sqlite_transient); sqlite3_bind_text(addstmt, 6, [blog utf8string], -1, sqlite_transient); sqlite3_bind_int(addstmt, 7, 0); if(sqlite_done != sqlite3_step(addstmt)) nsassert1(0, @"error while inserting data. '%s'", sqlite3_errmsg(_database)); sqlite3_reset(addstmt); }
which prints out correct values being sent methiod
storytitle -> converged security link -> http://...converged-security.html storydescription -> cyber-crime not new....etc storyhtml -> <p>cyber-crime not new....etc pubdate -> thu, 01 sep 2011 10:52:57 +0100 blog -> business continuity
the sqlite table looks this
table "contents" ( "id" integer primary key, "storytitle" text, "link" text, "storydescription" text, "storyhtml" text, "pubdate" datetime, "blog" text, "read" integer, "storyvideo" text, "storyvideothumb" text, "storyaudio" text, "issuea" text, "industrya" text, "servicea" text, "contactname" text, "contactphone" text, "contactaddress" text, "contactphrase" text, "contactphraseemail" text, "contactphrasename" text );
but inserted
"storytitle" correct string "link" correct string "storydescription" correct string "storyhtml" correct string "pubdate" correct string "blog" null "read" null "storyvideo" gets blog string (business continuity) "storyvideothumb" gets read value (0)
why inserting last 2 values wrong fields?
tia
for fame , glory (and points):
addstmt looks static and/or global. guess using same variable name elsewhere different insert statement.
Comments
Post a Comment