Solved

Fetch Data from remote server sqlite database in iphone xcode 5.1

Posted on 2012-03-21
7
7,551 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

     Intro      In this article, I will show you how to parse a JSON in Swift using an open source library called SwiftyJSON (https://github.com/SwiftyJSON/SwiftyJSON). If you haven't heard of a JSON before, it stands for JavaScript Object Notation…
A brief look into what is, how to use, and how to make GIFs
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…

739 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