Solved

Fetch Data from remote server sqlite database in iphone xcode 5.1

Posted on 2012-03-21
7
7,429 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

iCloud Drive was introduced after iOS 8 was launched last year. This drive is Apple’s online storage device that lets users sync their files and access them from all their Apple devices.   There is a lot of data that is not automatically backed up…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now