hi........every one.
i create one DB(StudentDB1.sqlite) & along with one table(StudentsTable1)
in XIB 3 Text Fields ,1 Button with action.........
like,,,,,,, NOw
- (IBAction)getDataFromSQLite:(id)sender {
NSString *studentDB_Path= [[NSBundle mainBundle]pathForResource:@"StudentDB1" ofType:@"sqlite"];
NSLog(@"studentDBPath is:%@",studentDB_Path);
const char *c_studentDB_Path = [studentDB_Path UTF8String];
//sqlite3_open(<#const char *filename#>, <#sqlite3 **ppDb#>);
sqlite3_open(c_studentDB_Path, &sqlite_studentDB);
NSString *selectStateMent = [NSString stringWithFormat:@"select * from StudentsTable1 where SNumber = \"%@\" ",self.sNumberTF.text];
NSLog(@"Entered Number is:%@",self.sNumberTF.text);
const char *c_selectStateMent = [selectStateMent UTF8String];
//sqlite3_prepare_v2(<#sqlite3 *db#>, <#const char *zSql#>, <#int nByte#>, <#sqlite3_stmt **ppStmt#>,<#const char **pzTail#>)
sqlite3_prepare_v2(sqlite_studentDB, c_selectStateMent ,-1, &(sqlite_preparedStatement),NULL);
while(sqlite3_step(sqlite_preparedStatement) == SQLITE_ROW){
NSLog(@"entering into While loop");
self.sNumberTF.text = [NSString stringWithFormat:@"%s",sqlite3_column_text(sqlite_preparedStatement,0)];
self.sNameTF.text = [NSString stringWithFormat:@"%s",sqlite3_column_text(sqlite_preparedStatement ,1)];
self.sMarksTF.text = [NSString stringWithFormat:@"%s", sqlite3_column_text(sqlite_preparedStatement,2)];
}
sqlite3_finalize(sqlite_preparedStatement);
sqlite3_close(sqlite_studentDB);
}
Every thing is fine , no issues.
compiling & path retrived ,bring values from TextFields.
but not Entering into while Loop it will go to directly Finlize ()
Reason?
Solution? Plese
0 comments:
Post a Comment