Hi there, i am new to the forum and would like to ask for help with a problem i am having.
I have a Sqlite database consisting of one table.
The table has 4 columns. I would like to extract from the table details from two columns dependent on another column.
To make that clearer i need to store the details of column 2 + column 3, if column 4 is equal to *variable 1.
I am looking to store this information into two seperate strings so the results from each column can be displayed on two seperate labels.
- I have created the .sql file and loaded it into Xcode
- i have connected to the database
- i now need to get the required details from the database (as explained above)
What i have worked out so far is this:
//connect to the database and open it.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dbPath = [documentsDirectory stringByAppendingPathComponent"Database.sql"];
//this is where i am attempting to get the required details and it all goes a bit wrong
if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)
{
NSString *name = variable1; //set name to my variable
NSString *sqlStr = [NSString stringWithFormat"select column2, column3 from table where column4 = '%@'", name];
const char *sql = [sqlStr UTF8String]; //convert our objective c string into C ???
sqlite3_stmt *selectStatement; // ???
and thats as far as i get...i have been trauling the web for something similar to give me a clearer picture but was hoping someone here might be able to help
From where i left off i am basically trying to get the values of column 2 + 3 stored in two seperate strings .
Any help would be appreciated.
And if any of this does not make sense....let me know
I have a Sqlite database consisting of one table.
The table has 4 columns. I would like to extract from the table details from two columns dependent on another column.
To make that clearer i need to store the details of column 2 + column 3, if column 4 is equal to *variable 1.
I am looking to store this information into two seperate strings so the results from each column can be displayed on two seperate labels.
- I have created the .sql file and loaded it into Xcode
- i have connected to the database
- i now need to get the required details from the database (as explained above)
What i have worked out so far is this:
//connect to the database and open it.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dbPath = [documentsDirectory stringByAppendingPathComponent"Database.sql"];
//this is where i am attempting to get the required details and it all goes a bit wrong
if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)
{
NSString *name = variable1; //set name to my variable
NSString *sqlStr = [NSString stringWithFormat"select column2, column3 from table where column4 = '%@'", name];
const char *sql = [sqlStr UTF8String]; //convert our objective c string into C ???
sqlite3_stmt *selectStatement; // ???
and thats as far as i get...i have been trauling the web for something similar to give me a clearer picture but was hoping someone here might be able to help
From where i left off i am basically trying to get the values of column 2 + 3 stored in two seperate strings .
Any help would be appreciated.
And if any of this does not make sense....let me know