searching for perfect code in updation query in sqlite manager

Discussion in 'iPhone' started by moon25, Jan 28, 2011.

  1. moon25 macrumors newbie

    Joined:
    Jan 25, 2011
    #1
    i m trying to update my db by using this,,all is going good but values are not updating in my db so plz gelp me..i m trying from last 4 days..
    thanks


    -(void)setDb1
    {

    ///sqlite3 *db = [appdelegate createDb];
    NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
    NSString *str_username=[defaults stringForKey:mad:"keyforusername"];

    NSString *selectSql;
    //NSMutableString *strtxt1=@"";

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:mad:"DatingDatesDB.sql"];
    NSLog(@"set data");
    if(sqlite3_open([path UTF8String],&db)==SQLITE_OK)
    {
    const char* sql1;
    //sql1=[[NSString stringWithFormat:mad:"INSERT INTO UserDetailstbl VALUES('%@','%@','%@','%@','%@','','','','','','');",txt_fname.text,txt_lname.text,txt_email.text,txt_uname.text,txt.text] cStringUsingEncoding:NSUTF8StringEncoding];
    //retVal=sqlite3_exec(db,sql1,NULL,NULL,&str1);

    const char* sql2;
    ///sql2=[[NSString stringWithFormat:mad:"INSERT INTO Dates VALUES('%@','%@','%@','%@','%@','%@');",txt_pstartdate.text,txt_hmdcycle.text,txt_hmdplast.text,txt_hmdpstart.text,txt_pdays.text,txt_odays.text]cStringUsingEncoding:NSUTF8StringEncoding];
    sql2=[[NSString stringWithFormat:mad:"UPDATE UserDetailstbl SET P_Start_Date='%@',HMD_cycle='%@',HMD_Plast='%@',HMD_Pstart='%@',P_days='%@',O_days='%@' WHERE UserName1='%@';",txt_pstartdate.text,txt_hmdcycle.text,txt_hmdplast.text,txt_hmdpstart.text,txt_pdays.text,txt_odays.text,str_username]cStringUsingEncoding:NSUTF8StringEncoding];


    retVal=sqlite3_exec(db,sql2,NULL,NULL,&str1);

    //NSUserDefaults *character=[NSUserDefaults standardUserDefaults];
    //[character setObject:str3 forKey:mad:"keyforCharacter"];

    if(retVal)
    {
    }

    }
    sqlite3_close(db);
    }
     
  2. DDustiNN macrumors 65816

    DDustiNN

    Joined:
    Jan 27, 2011
    #2
    What is "&str1"? I see you using them in your exec, but I don't see it defined anywhere...
     

Share This Page