Solved

Fetch Data from remote server sqlite database in iphone xcode 5.1

Posted on 2012-03-21
7
7,475 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
  • 4
  • 3
7 Comments
 
LVL 19

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 19

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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

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 19

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 19

Expert Comment

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

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Are you looking to clear some space on your phone for the latest iOS 8 update? Did you switch to Spotify so you no longer need to keep music native on your phone? Run out of space for taking photos while in the middle of vacation? Sometimes the quic…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
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…

770 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