Inserting Rows in Database Using Sqlite Iphone - iphone

I have the following code n i have 4 records in data base but loop is running 2 times n getting only first row two times whats a problem in my code?
- (void) getAllRowsFromTableName:(NSString *)tableName{
   NSString *qsql = [NSString stringWithFormat:#"SELECT * FROM '%#'",tableName];
 
   NSLog(#"query is :%#",qsql);
   sqlite3_stmt *statement;
   if (sqlite3_prepare_v2(db,[qsql UTF8String] , -1, &statement,nil) == SQLITE_OK) {
       while (sqlite3_step(statement) == SQLITE_ROW) {
           NSLog(#"loop");
           int catId = sqlite3_column_int(statement, 1);
            NSLog(#"***CatId is :%d",catId);
               sqlite3_finalize(statement);
       }
       sqlite3_finalize(statement);
   }

Wow! Another that use sqllite3 natively!! :)
I would suggest you an external lib (2 files) named FMDB, that is a wrapper to sqllite3.
https://github.com/ccgus/fmdb
Easy to use. Hope this helps.

Just to complete and close this question I am putting my comment in answer.
Try with commenting the sqlite3_finalize(statement); inside the while loop.
Explaination:
SQLite.org says
The sqlite3_finalize() function is called to delete a prepared
statement.
Also,
The application must finalize every prepared statement in order to
avoid resource leaks. It is a grievous error for the application to
try to use a prepared statement after it has been finalized. Any use
of a prepared statement after it has been finalized can result in
undefined and undesirable behavior such as segfaults and heap
corruption.
Thanks,

Related

Check if a file or directory has a specific alternative data stream attached to it?

I am writing a function or a commandlet (I want to call it Set-Metadata) that will allow me to attach metadata information to directories and files. Its for a file manager columns that expect ADS data
I am currently stuck on the logic part.
Before I write any metadata to a file via its NTFS ADS I would first like to check if the file has a specific stream so that I don't overwrite anything and instead append text to the stream.
function Set-MetaData(
    [Parameter(Mandatory=$true, ValueFromPipeline=$true)]
    [string]
    $Path,
    [Alias("C", "Cat")] #Replace Column Content
    [String]$Category,
    [Alias("PC", "PCat")] #Prefix to the content in  Column
    [String]$PCategory,
    [Alias("SC", "SCat")] #Suffix to the content in  Column
   
    [String]$SCategory){
        process {
        Switch ($PSBoundParameters.Keys){
            'Category'{
            }'PCategory'{
            }'SCategory'{
                if(...) #file has a stream called "multitags.txt"
                # Add-Content -Path $Path -Stream  multitags.txt -Value $Category
    }}
}
I have taken the liberty to cross post this question on other forums as well.
Any help would be greatly appreciated!

How can we split a column with multiple values separated by "space" delimiter into multiple rows in Qlik using any logic

I have one requirements as below. Suppose I have a column with below values
rowno          Column
1                MS Teams slack skype
2                 slack
3                 skype
I want to split the first row as below 
rowno          Column
1              MS Teams
1              slack
1              skype
2              slack
3              skype
How I can not use sub field function since it will split MS Teams to MS ,Teams. Instead can I use wildmatch? Please suggest how I can achieve this in Qlik Sense?
I'd probably do it in 2 parts... first to replace the MS Teams value with MS_Teams and then do the subfield. You could add another part to get rid of the _ at the end.
Table:
Load
rowno,
subfield(Column_clean,' ') as Column;
Load
rowno,
replace(Column,'MS Teams','MS_Teams') as Column_clean
from source;

is there any way to call multiple datas in jasper?

I wanna ask about how to display the data below the previous data because when i tried to display the data, the next data that i have displayed in the next page, the thing that i want is i want to display the items below from the previous one. 
for example of the table and the data are
table name : Tax
Tax code           tax name                   tax amount
1                  regresive tax              2000.00
2                  capital gain tax          3000.00
3                  property tax               5000.00
the query is
select tax.name,tax.amount
from table tax
and the output is:
page 1
regresive tax        2000.00
page 2
capital gain tax     3000.00
page 3
property tax           5000.00
the output I want is:
page 1
regresive tax        2000.00
capital gain tax    3000.00
property tax         5000.00
If you're using Text Fields for displaying data, make sure you're placing them in the Detail band.
Also make sure you don't have much whitespace below the text fields - so, for example, if the height of the text field is 30px, the height of the detail band should also be about that much (if there are no other elements there).

Update plist from background

Is it possible to read or write to plist when the application is in background state?
It is not possible to read your plist when your application is in the background, because your application is not running more than 10 minutes in the background state. There are only three options for keeping your application running more than 10 minutes in the background.
If you want to read and write your plist, do this when your application comes to the foreground state. For this you can read and write your plist in the application became active delegate method.
try this one..
- (void)readPlist
{
    NSString *filePath = #"/System/Library/CoreServices/SystemVersion.plist";
        NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
       
        NSString *value;
        value = [plistDict objectForKey:#"ProductVersion"];
     
        /* You could now call the string "value" from somewhere to return the value of the string in the .plist specified, for the specified key. */
}
- (void)writeToPlist
{
    NSString *filePath = #"/System/Library/CoreServices/SystemVersion.plist";
        NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
       
        [plistDict setValue:#"1.1.1" forKey:#"ProductVersion"];
        [plistDict writeToFile:filePath atomically: YES];
/* This would change the firmware version in the plist to 1.1.1 by initing the NSDictionary with the plist, then changing the value of the string in the key "ProductVersion" to what you specified */
}
Hope this helps you!

iphone sinin and sinup code

i want the solution of below question, i dont know how to store sinup information in Plist, can any one knows please help.
Thanks in advance
Use  Dummy  data  but  the  dummy  data  must  not  be  in  the  code  ,it  should  either   be   in   an   external   file   (plist/xml)   or   in   a   separate   constant   file.This   improves   the   code  management.  
All  screens  must  comply  to  Portrait  and  Landscape  View  Mode    
1.   The   App   will   begin   with   the   Login   Screen,   The   screen   should   be   having   same   functionality  as  any  website.  
     a.  Login  
     b.  Sign  Up  
     c.  Maximum  Tries  (3)  then  lock  the  app  
     d.   Requires   Answer   to   secret   question   to   unlock   which   will   be   accepted   in   sign   up
If you are looking for storing small data like user credentials look for NSUserDefault.
For automatic login, if the user has logged in previously look this.
You can create a new .plist file to store the information.
Add New File in your project, of type "Property list". Its under the "Resource tab", on "Mac OS X" in the left pane of your xcode.
Once created, Now add new items in to it. The "Key" will be used the retrieve the value through the coding.
To retrieve the values in the coding, from .plist file, you can use this code:
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSDictionary* defaultSettings = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:#"YOUR_PLIST_FILE_NAME.plist" ofType:nil]];
[defaults registerDefaults:defaultSettings];
NSString *sName = [defaultSettings objectForKey:#"Name"]; //the Name is the Key in .plist file, so its corresponding value will be fetched and store in sName variable
NSString *defaultDomain = [defaultSettings objectForKey:#"domain"];
I hope it helps :)