Start New Discussion within our Software Development Community

HI,
I created an app to add a clinc details to the sqlite3 db from xcode. the code is below. The (sqlite3_step(statement1) == SQLITE_DONE) does not execute it. I dont get an error or anything. I can't figure out what exactly is wrong.Apprecite if someone can tell me what i am doing wrong here.

Appreciate a response.

Thansk,

[appDelegate createOpenDB];

    sqlite3_stmt *statement1;
    const char *dbpath1 = [appDelegate.databasePath UTF8String];

    if (sqlite3_open(dbpath1, &influenzaDB) == SQLITE_OK)
    {
        NSLog(@"Sqlite open true");

        //NSLog(@"Statement %@" , statement);
        NSString *insertSQL1 = [NSString stringWithFormat:@"INSERT INTO CLINIC(CLINICID, CLINICNAME, STARTDATE, ADDRESS, CITY, STATE, ZIP, PASSWORD) VALUES (\"%@\", \"%@\", \"%@\",\"%@\", \"%@\", \"%@\",\"%@\", \"%@\")",fluName.text, patientName.text, patientAge.text, patientSex.text, ethnicity.text, patientStatus.text, tratment.text, tratment.text];


        const char *insert_stmt1 = [insertSQL1 UTF8String];


        if( sqlite3_prepare_v2(influenzaDB, insert_stmt1,-1, &statement1, NULL) == SQLITE_OK){


        if (sqlite3_step(statement1) == SQLITE_DONE)
        {

            status.text = @"Clinic added";


        } else {
            status.text = @"Failed to add clinic";
                  }
        sqlite3_finalize(statement1);
        sqlite3_close(influenzaDB);
        }
    }

Are you sure your first if statement is not the problem? Is the text displaying "Failed to add clinic"? If it isn't then your sqlite3_prepare_v2 statement is the problem and you'll need to find out what status code is being returned

This article has been dead for over six months. Start a new discussion instead.