Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

inserting data to database(iphone)
#1

-(IBAction)setdata
{

NSMutableArray *values=[[NSMutableArray alloc]init];

[values addObject:txt1.text];

[values addObject:txt2.text];


[values addObject:txt3.text];


NSString *dbpath=[self getdbpath];

if(sqlite3_open([dbpath UTF8String], &database)==SQLITE_OK)
{
if(addStmt==nil)
{
const char *sql="insert into Details(name,adress,rollno)
values(?,?,?)";

if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL)!
=SQLITE_OK)
{
NSAssert1(0,@"error while creating
statement.'%s'",sqlite3_errmsg(database));
}
}
sqlite3_bind_text(addStmt,1,[[values objectAtIndex:
0]UTF8String],-1,SQLITE_TRANSIENT);

sqlite3_bind_text(addStmt,2,[[values objectAtIndex:
1]UTF8String],-1,SQLITE_TRANSIENT);

sqlite3_bind_text(addStmt,3,[[values objectAtIndex:
2]UTF8String],-1,SQLITE_TRANSIENT);

if(SQLITE_DONE!=sqlite3_step(addStmt))
NSAssert1(0,@"error.'%s'",sqlite3_errmsg(database));
sqlite3_reset(addStmt);
}

[values1 copy:values];

[values release];
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)