Solved

Fetch Data from remote server sqlite database in iphone xcode 5.1

Posted on 2012-03-21
7
7,596 Views
Last Modified: 2012-03-22
My database store in server : Datalist.sqlite3

Now i want to access this database in my iphone,

How to access server database in iphone?

My code as below:
------------------------------
- (void) copyDatabaseIfNeeded {
      
      //Using NSFileManager we can perform many file system operations.
      NSFileManager *fileManager = [NSFileManager defaultManager];
      NSError *error;
      NSString *dbPath = [self getDBPath];
      BOOL success = [fileManager fileExistsAtPath:dbPath];
      
      if(!success) {
            
            NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Datalist.sqlite3"];
            success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
            
            if (!success)
                  NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
      }      
}

- (NSString *) getDBPath {
      
      //Search for standard documents using NSSearchPathForDirectoriesInDomains
      //First Param = Searching the documents directory
      //Second Param = Searching the Users directory and not the System
      //Expand any tildes and identify home directories.
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
      NSString *documentsDir = [paths objectAtIndex:0];
      return [documentsDir stringByAppendingPathComponent:@"Datalist.sqlite3"];
}
----------------------------------------------------------------------------------------------------------------------------------

my server access by this url

http://www.test.com/App_Data/Datalist.sqlite3

Here is store my Database, I want to access this database in my iphone.

How can i access?

Please give me proper solutions

Thank you
0
Comment
Question by:citadelind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 20

Assisted Solution

by:darbid73
darbid73 earned 500 total points
ID: 37747977
That requires a bit of work.  How about some tutorials like these.

ToDo List using SQlite3
A SQlite3 Application
Another Shoppping List Example

There is one other solution and that is to use core Date;
This is my favourite website on learning things.
0
 

Author Comment

by:citadelind
ID: 37751002
But i want to access server database which is stored on live site on this url

http://www.test.com/App_Data/Datalist.sqlite3

How can i access directly from the server?

I do not use local database, using server live database in my iphone.....

Give me properly solutions.....

Thanking you...
0
 
LVL 20

Assisted Solution

by:darbid73
darbid73 earned 500 total points
ID: 37751012
Ah - you cannot access the database directly then.  You need a web service.  

For Example here is Ray's

The equivalent in Microsoft is WCF and a REST Service.  I have not found a good tutorial on this one, but there are bits and pieces in the internet if you look long enough.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:citadelind
ID: 37751026
ok thanks for giving me nice tutorial,

One more thing, Same solution i want to connect with Microsoft SQL server 2008 through Web Services to iphone

Through web service to connect iphone?

I do not know how is build it out and how to do that?

Please give me properly example so i can understand properly and implement in my iphone application....

Thanking you....
0
 
LVL 20

Accepted Solution

by:
darbid73 earned 500 total points
ID: 37751059
Like I said above a nice tutorial on MS ~ iOS is hard to find.

Here is one on WCF but honestly just google wcf tutorial and you will get lots of stuff, mostly in C#. Also if you add iPhone to the search you will get lots of examples of how to consume the WCF Service.
0
 

Author Closing Comment

by:citadelind
ID: 37751064
Thank you giving nice solutions
0
 
LVL 20

Expert Comment

by:darbid73
ID: 37751133
good luck.  I found WCF and all this microsoft server stuff hard work.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The release of the iPhone 6 and iPhone 6 Plus was a complete game changer for Apple. Steve Jobs had even showed his distaste for larger phones, calling them “Hummers”. But to compete with larger smartphones, Apple finally introduced the iPhone 6 wit…
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question