Insert Record Using Insert method and query:
- (IBAction)btnAddClick:(id)sender {
//Inser New Employee Query
NSString *strEmpName = @"abc";
NSString *strEmpSalary = @"1000";
NSString *strEmpDesignation = @"Devloper";
NSString *strInsertQuery = [NSString stringWithFormat:@"INSERT INTO EmployeeTbl (EmpName,EmpSalary,EmpDesignation) VALUES('%@','%@'.'%@'",strEmpName,strEmpSalary,strEmpDesignation];
//Inser Thsi Query
[[Database shareDatabase] Insert:strInsertQuery];
}
Updated Record Using updated method and query:
- (IBAction)btnUpdateClick:(id)sender {
//Update Employee Query
NSString *strUpdateEmpName = @"abc";
NSString *strUpdateEmpSalary = @"2000";
NSString *strUpdateEmpDesignation = @"Devloper";
NSString *strUpdateQuery = [NSString stringWithFormat:@"UPDATE EmployeeTbl SET EmpName = '%@',EmpSalary = '%@',EmpDesignation = '%@' WHERE EmpNo = 1",strUpdateEmpName,strUpdateEmpSalary,strUpdateEmpDesignation];
[[Database shareDatabase] Update:strUpdateQuery];
}
-------------------------------
Delete Record using delete method and query :
(IBAction)btnDeleteClick:(id)sender {
//Delete Query
NSString *strDeleteQuery = [NSString stringWithFormat:@"DELETE FROM EmployeeTbl WHERE EmpNo = %@",@"1"];
[[Database shareDatabase] Update:strDeleteQuery];
}-----------------------------------------------
Select query in Sqlite databse:
//Select DB functions from Database
NSString *strSelectQuery = [NSString stringWithFormat:@"SELECT * FROM DBFunctions"];
mutArrayDBFunctions = [[Database shareDatabase] SelectAllFromTable:strSelectQuery];
- (IBAction)btnAddClick:(id)sender {
//Inser New Employee Query
NSString *strEmpName = @"abc";
NSString *strEmpSalary = @"1000";
NSString *strEmpDesignation = @"Devloper";
NSString *strInsertQuery = [NSString stringWithFormat:@"INSERT INTO EmployeeTbl (EmpName,EmpSalary,EmpDesignation) VALUES('%@','%@'.'%@'",strEmpName,strEmpSalary,strEmpDesignation];
//Inser Thsi Query
[[Database shareDatabase] Insert:strInsertQuery];
}
Updated Record Using updated method and query:
- (IBAction)btnUpdateClick:(id)sender {
//Update Employee Query
NSString *strUpdateEmpName = @"abc";
NSString *strUpdateEmpSalary = @"2000";
NSString *strUpdateEmpDesignation = @"Devloper";
NSString *strUpdateQuery = [NSString stringWithFormat:@"UPDATE EmployeeTbl SET EmpName = '%@',EmpSalary = '%@',EmpDesignation = '%@' WHERE EmpNo = 1",strUpdateEmpName,strUpdateEmpSalary,strUpdateEmpDesignation];
[[Database shareDatabase] Update:strUpdateQuery];
}
-------------------------------
Delete Record using delete method and query :
(IBAction)btnDeleteClick:(id)sender {
//Delete Query
NSString *strDeleteQuery = [NSString stringWithFormat:@"DELETE FROM EmployeeTbl WHERE EmpNo = %@",@"1"];
[[Database shareDatabase] Update:strDeleteQuery];
}-----------------------------------------------
Select query in Sqlite databse:
//Select DB functions from Database
NSString *strSelectQuery = [NSString stringWithFormat:@"SELECT * FROM DBFunctions"];
mutArrayDBFunctions = [[Database shareDatabase] SelectAllFromTable:strSelectQuery];