我在申请时想利用最新询问?
在我的申请中,有两阶段完成登记工作。
页: 1 (一) 登记表和提交纽特?
在点击提交纽特时,所有细节都应列入我的qlite表格。
页: 1
表格中节省的所有价值都应由用户在该网页上查看,如果他想要作任何改动,他应当能够这样做。 一旦用户编辑了某些价值,他就会继续播报所有数值,应当更新?
但我已尝试这样做,但我无法更新最后的进入价值?
下面是我的代码第1页。
-(void)submit
{
if( ([UserName.text isEqualToString:@""]) || ([Password.text isEqualToString:@""]) ||
([ConfirmPassword.text isEqualToString:@""]) || ([Name.text isEqualToString:@""]) ||
([Email.text isEqualToString:@""]) || ([ContactNO.text isEqualToString:@""]) ||
([MobileNo.text isEqualToString:@""]) || ([Address.text isEqualToString:@""]) )
{
UIAlertView *ErrorAlert = [[UIAlertView alloc] initWithTitle:@"Error!!"
message:@"Please fill in the details." delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[ErrorAlert show];
[ErrorAlert release];
iii
else
{
Confirmation_form *conForm = [[Confirmation_form alloc] initWithNibName:@"Confirmation_form" bundle:nil];
conForm.data = UserName.text;
conForm.data1 = Password.text;
conForm.data2 = ConfirmPassword.text;
conForm.data3 = Name.text;
conForm.data4 = Email.text;
conForm.data5 = ContactNO.text;
conForm.data6 = MobileNo.text;
conForm.data7 = Address.text;
sqlite3_stmt *statement;
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &test1DB) == SQLITE_OK)
{
NSString *insertSQL = [NSString stringWithFormat:@"INSERT INTO test(UserName, Password, ConfirmPassword, Name, Email, ContactNO, MobileNo, Address) VALUES ("%@", "%@", "%@", "%@", "%@", "%@", "%@", "%@")",UserName.text, Password.text, ConfirmPassword.text, Name.text, Email.text, ContactNO.text, MobileNo.text, Address.text];
const char *insert_stmt = [insertSQL UTF8String];
sqlite3_prepare_v2(test1DB, insert_stmt, -1, &statement, NULL);
if(sqlite3_step(statement) == SQLITE_DONE)
{
//status.text = @"Contact added";
UserName.text = @"";
Password.text = @"";
ConfirmPassword.text = @"";
Name.text = @"";
Email.text = @"";
ContactNO.text = @"";
MobileNo.text = @"";
Address.text = @"";
sqlite3_last_insert_rowid;
rowID = sqlite3_last_insert_rowid(test1DB);
NSLog(@"last inserted rowId = %d",rowID);
sqlite3_reset(statement);
sqlite3_finalize(statement);
sqlite3_close(test1DB);
[self.navigationController pushViewController:conForm animated:YES];
iii
iii
iii
iii
从上述法典来看,我能够获得row,但我无法在更新询问时使用这种row。
以下是我的代码第2页。 更新守则:
-(IBAction)Update;
{
sqlite3_stmt *statement;
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &test1DB) == SQLITE_OK)
{
NSString *insertSQL = [NSString stringWithFormat:@"UPDATE test SET UserName= %@ ,Password= %@ ,ConfirmPassword= %@ ,Name= %@ ,Email= %@ ,ContactNO= %@ ,MobileNO= %@ ,Address= %@ WHERE ID= %@ ",UserName.text,Password.text,ConfirmPassword.text, Name.text, Email.text, ContactNO.text, MobileNo.text, Address.text, sqlite3_last_insert_rowid(test1DB)];
const char *insert_stmt = [insertSQL UTF8String];
sqlite3_prepare_v2(test1DB, insert_stmt, -1, &statement, NULL);
if(sqlite3_step(statement) == SQLITE_DONE)
{
sqlite3_step(statement);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"Record added" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
alert = nil;
sqlite3_finalize(statement);
sqlite3_close(test1DB);
iii
else {
sqlite3_step(statement);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"Record notadded" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
alert = nil;
iii
iii
iii