iphone xcode sqlite3_open remote host

i try to get a connection my server, with the sqlite3_open command!

my question...is it possible to that? i got the following code...

 // Get the path to the documents directory and append the databaseName
 databaseName = @"AnimalDatabase.sql";
 NSString *serverpath = @"http://localhost/app/";

 databasePath = [serverpath stringByAppendingPathComponent:databaseName];


and then this here

-(void) readAnimalsFromDatabase {
 // Setup the database object
 sqlite3 *database;

 // Init the animals Array
 animals = [[NSMutableArray alloc] init];

 // Open the database from the users filessytem
 if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
  // Setup the SQL Statement and compile it for faster access
  const char *sqlStatement = "select * from animals";
  sqlite3_stmt *compiledStatement;
  if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
   // Loop through the results and add them to the feeds array
   while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
    // Read the data from the result row
    NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
    NSString *aDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
    NSString *aImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];

    // Create a new animal object with the data from the database
    Animal *animal = [[Animal alloc] initWithName:aName description:aDescription url:aImageUrl];

    // Add the animal object to the animals Array
    [animals addObject:animal];

    [animal release];
   }
  }
  // Release the compiled statement from memory
  sqlite3_finalize(compiledStatement);

 }
 sqlite3_close(database);

}

any suggestion??

Answers


Where you get the idea that SQLite can open database from URL?? It can open files only (or, create temporary db in memory).


The answer is just NO, there are lot of mistakes in your code anyway. For example:

databaseName = @"AnimalDatabase.sql";

Where did you get this. iPhone is working with sqlite database, it has nothing in common with sql files:)


Need Your Help

Codeigniter's redirect is not passing variable data

codeigniter codeigniter-2

I have a form to update some profile information. After making changes when the user clicks on the submit button my to be redirected to the profile page.

Response.Write() in WebService

asp.net json web-services asmx

I want to return JSON data back to the client, in my web service method. One way is to create SoapExtension and use it as attribute on my web method, etc. Another way is to simply add [ScriptService]

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.