如何在iphone中更新同一字段的服务器数据库中的数据

如何在iphone中更新同一字段的服务器数据库中的数据,iphone,objective-c,Iphone,Objective C,我正在更新我的数据,但它不更新发生的原因 我想如果任何注册用户想将数据从旧改为新,那么我会给出一个更新页面,用户在其中更改数据,但除了用户名,我尝试了很多,这不是将数据更新到服务器数据库表我的cod是正确的还是错误的 -(void)sendRequest { NSString *post = [NSString stringWithFormat:@"firstname=%@&lastname=%@&Username=%@&Password=%@&

我正在更新我的数据,但它不更新发生的原因

我想如果任何注册用户想将数据从旧改为新,那么我会给出一个更新页面,用户在其中更改数据,但除了用户名,我尝试了很多,这不是将数据更新到服务器数据库表我的cod是正确的还是错误的

 -(void)sendRequest
    {
        NSString *post = [NSString stringWithFormat:@"firstname=%@&lastname=%@&Username=%@&Password=%@&Email=%@",txtfirstName.text,txtlast.text,txtUserName.text,txtPassword.text,txtEmail.text];
        NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; 
        NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; 
        NSLog(@"%@",postLength);
        NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; 
        [request setURL:[NSURL URLWithString:@"http://192.168.0.1:96/JourneyMapperAPI?RequestType=Register&Command=SET"]]; 
        [request setHTTPMethod:@"POST"]; 
        [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; 
        [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; 
        [request setHTTPBody:postData];

        NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

        if (theConnection) {
            webData = [[NSMutableData data] retain];
            NSLog(@"%@",webData);
        }
        else 
        {

        }

    }



    -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response 
    {   
        [webData setLength: 0]; 
    } 

    -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 
    {         
        [webData appendData:data]; 

    } 

    -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error 
    {     
        [connection release];  
        [webData release]; 
    } 

    -(void)connectionDidFinishLoading:(NSURLConnection *)connection 
    {      
        NSString *loginStatus = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding]; 
        NSLog(@"%@",loginStatus);  

        }

您需要启动连接:

    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

    if (theConnection) {
        webData = [[NSMutableData data] retain];
        NSLog(@"%@",webData);
        [theConnection start];
    }
    else 
    {

    }