Solved

Fetch Data from remote server sqlite database in iphone xcode 5.1

Posted on 2012-03-21
7
7,452 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

930 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

14 Experts available now in Live!

Get 1:1 Help Now