How to store data from iOS app in a remote database safely and Apple friendly? - objective-c

How would one go about incorporating, for example a 'mailing list' where user could fill in a text field for 'name' and 'email address' and click a submit button that would add the data to a database on a remote server.
Property lists would be the most convenient but the whole plist would need to be downloaded to the users device, modified and reuploaded (which looks involved and easily corrupted). SQLite is likewise built for a local database. Is there a simple way to do this or is server side php scripting the only real answer?

I see a lot of replies about this question that specify a specific database type and programming solution. The real solution is a web service, of any kind, and a data store, of any kind.
This could be SQL Server with a web service written in ASP.NET. It could also just as easily be a MySQL database with an interface written in PHP. But for the love all things secure don't try to attach to a database directly.

It would appear the most practical method at this time is a remote MySQL (or similar) database queried from php scripts that are called from the app via NSURLRequests (. Information about the query can be sent using the _POST variable.

Related

Users to fetch files remotely

I am using ADO to connect to an access database from an excel spreadsheet using code written in vb. The spreadsheet allows someone to retrieve files stored locally on my machine according to what they enter in certain cells and from interrogating the database. This has worked well which presents the frightening prospect of me now feeling encouraged!...
It is my wish to give a copy of my spreadsheet to people but retain the files and database on my own computer or a dedicated server. ( I do not want the users to be able to access anything other than a view onto the data or the files that I allow them to access). I totally appreciate their are a myriad of alternative technologies that I could and might need to achieve this. But I really am quite a simpleton and would like to be able to simply amend my connection string with something that uses an IP address and similarly with the files. Is this even possible? Can someone advise me where to even start looking for a solution if it is not? I've browsed through stuff on VPN's, application servers, ASP's etc. without even knowing if it is relevant and, as I say, I need the dumbsters solution. I'm happy to read - but what......should I look at VB.net?
A VPN would allow a similar setup to what you have now in as much as your would need to modify the connection string and file paths (to network share paths) but has drawbacks:
Users/you would need to configure a VPN client
Your machine would be the host so would need to be always-on with sufficient bandwidth
Users would be logging on to your machine so you would need to manage access rights/security
This is difficult to scale and a pain in to manage, which is something that is also true of attempting to serve Access content over the internet.
A more standard way to do this would be to:
Get an ASP.NET hosting account with SQL Server support (or set this up on your machine)
Migrate the Access data to SQL Server (which unlike Access is specifically designed to support multiple users over a network)
Update your VBA connection string and make any required changes to your SQL
Create an ASP page that reads the files stored on the server and returns their content
Modify the code you have that loads files from disk to instead query this ASP page over HTTP and read its contents
Retaining Access; you could also create a ASP page that executes queries, reads the data and converts it to XML returned to your spreadsheet for processing.

How to migrate shared database from Access to SQL Express

I have been using MS Access databases via DAO for many years, but feel that I ought to embrace newer techniques.
My main application runs on end user PCs (no server) and uses a shared database that is created and updated on-the-fly. When the application is first run it detects the absence of a database and creates a new empty one.
Any local user running the application is allowed to add or update records in this shared database. We have a couple of other shared databases, that contain templates, regional information, etc., but these are not updated directly by the application.
Updates of the application are released from time to time and each new update checks the main database version and if necessary executes code to bring the database up to the latest specification. This may involve the creation or deletion of tables and/or columns. New copies of the template databases are also included as part of the update.
Our users are not required to be computer-literate and should not need to run any sort of database management software beyond those facilities provided by the application.
It all works very nicely with DAO/Access, but I'm struggling to find how to do it with SQL Express. The databases seem to be squirrelled away in locations that are user-specific and database creation and update seems at best awkward to do by program code alone.
I came across some references "Xcopy deployment" that looks like it could be promising, but there seem to be references to "user instances" that sound suspiciously like something that's not shared. I'd appreciate advice from anyone who has done it.
It sounds to me like you haven't fully absorbed the fundamental difference between the Access Database Engine (ACE/Jet) and SQL Server:
When your users launch your Access application it connects to the Access Database Engine that has been installed on their machine. Their copy of ACE/Jet opens the shared database file (.accdb or .mdb) in the network folder. The various instances of ACE/Jet work together to manage concurrent updates, record locking, and so on. This is sometimes called a "peer-to-peer" or "shared-file" database architecture.
With an application that uses a SQL Server back-end, the copies of your application on each user's machine connect over the network to the same instance of SQL Server (that's why it's called "SQL Server"), and that instance of SQL Server manipulates the database (which is stored on its local hard drive) on behalf of all of the clients. This is called "client-server" or "server-based" database architecture.
Note that for a multi-user database you do not install SQL Server on the client machines, you only install the SQL Server Client components (OleDb and ODBC drivers). SQL Server itself is only installed in one place: the machine that will act as the SQL... Server.
re: "database creation and update seems at best awkward to do by program code alone" -- Not at all, it's just "different". Once again, you pass all of your commands to the SQL Server and it takes care of creating the actual database files. For example, once you've connected to the SQL Server if you tell it to
CREATE DATABASE NewDatabase
it will create the database files (NewDatabase.mdf and NewDatabase_log.LDF) in whatever local folder it uses to store such things, which is usually something like
C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA
on the server machine.
Note that your application never accesses those files directly. In fact it almost certainly cannot do so, and indeed your application does not even care where those files reside or what they are called. Your app simply talks to the SQL Server (e.g. ServerName\SQLEXPRESS) and the server takes care of the details.
Just to update on my progress. Inspired by suggestions here and this article on code project:
http://www.codeproject.com/Articles/63147/Handling-database-connections-more-easily,
I've created a wrapper for the ADO.NET methods that looks quite similar to the DAO stuff that I am familiar with.
I have a class that I can use just like a DAO Database. It wraps ADO methods like ExecuteReader, ExecuteNonQuery, etc. with overloads that can accept a SQL parameter. This allows me to directly replace DAO Recordsets with readers, OpenRecordset with ExecuteReader and Execute with ExecuteNonQuery.
Each method obtains and releases the connection from its parent class instance. These in turn open or close the underlying connection as required depending on the transaction state, if any. So a connection is held open for method calls that are part of a transaction, but closed immediately for a single call.
This has greatly simplified the migration of my program since much of the donkey work can be done by a simple "find and replace". The remaining issues are then relatively easy to find and sort out.
Thanks, once again to Gord and Maxwell for your advice.
This answer is too long to right down... but go to Microsoft page, there they explain how to make it: http://office.microsoft.com/en-us/access-help/move-access-data-to-a-sql-server-database-by-using-the-upsizing-wizard-HA010275537.aspx
I hope this help you!!

How to deploy windows form application with entity framework

I am busy developing my own application, it uses a sql server database and it is connected through an entity framework. I use store procedures to insert, update, delete, select from my database.
The app works perfect on my machine even when I publish it. But my problem comes in when I try to install the app to my friend’s computer. It crashes and does not start because it cannot connect to the database.
Is there a way to publish my app with the database, without importing all the tables, store procedures and database into my friend’s pc? I just want to make it so the user just has to install the app and it works.
Your app relies on the db to work, so if you want to put it on your friends PC then you need to make the DB available somewhere, whether it be a local copy or a copy stored on a server somewhere running SQL.
How are you storing your connection string? Is it hard coded in the app or are you utilising the app.config file? To do what you're trying to do you'll need to put the connection string into the app.config file, so you can change it depending on the installation.
either that or
if you want to run your app without data, put a demo flag or something into the app.config file. Put some code into your app to check this value, if it's true then bypass the SQL code and maybe supply some demo data which is hard coded.
Does this make sense?
You could use SQL CE, but you may find it a little more difficult to 'design' your database in it if you are more used to working in SQL Server.
Have you considered SQL Server Express as an option?
On the connection string issue, you can now get the data connection wizard that Microsoft use in Visual Studio via Nuget; this makes adding a way to dynamically configure connection strings on your clients machine much easier.
Lastly, connection strings for the entity framework are different from standard SQL connection strings. Make sure that you clearly understand the differences before you start trying to configure them programmatically. Julie Lerman's excellent book on the Entity Framework explains the differences well.

Directly perform SQL queries from iPhone to an online server

I'm a newbie and tend to do a simple iOS applications.
The mission is making an app that does the registeration for a person and then upload that data to an online server.
In detail, I want to insert, delete, update data directly to online server.
Would anyone show me what I have to do with (tool, library...)?
I have worked with SQlite to make a local database for the iPhone and it worked well, now it is about dealing with an online server.
For performing remote request there are two ways:
1) https://github.com/smhuang426/MySqueakQl - this is "basic" implementation for remote access to DB. http://www.karlkraft.com/index.php/2010/09/17/mysql-for-iphone-and-osx/ - more advanced, in articles you may some instructions how use this framework. In this case you use SQL C API and you can write your own special classes. Example: http://blog.iosplace.com/?p=30 , http://zetcode.com/tutorials/mysqlcapitutorial/ and description of C API http://dev.mysql.com/doc/refman/5.0/en/c-api-function-overview.html
2) PHP script that posted on online server, you use async ASIHTTP (or ordinary NSRequest) that send to this script, and script works directly with sql DB on tis server. Example ( iOS no communication between iPhone app and MySQL database via PHP). In this case you achieved more security, but also there some limitations like decrease of app's speed and server must supply PHP.
Good luck!
What you need is some kind of remote API available which you will use to interface the iPhone application and say, a MySQL database.

Pulling Data From an SQL Database in HTML 5

I am trying to develop a BlackBerry application that will show data from an SQL Database from a server. I was researching the new HTML 5 option for blackberry (WebWorks) and noticed that it apparently cannot connect to any server data by itself. Some links state that I would need javascript coding to obtain it. I looked into the option of PhoneGap (link here: http://phonegap.com/) and decided I'd try using HTML 5 to produce the application. I have never touched SQL databases before and I am wondering how I would connect the two; meaning how do you pull data from the server given that you are working with HTML5?
I have looked at:
Where is data stored when using an HTML 5 Web SQL Database
Process for pulling data from a sql database
among others but I am still unsure as to what to do. I would be looking to "view" the data from the server and display it on the app. It would be something of the sort:
- HomeScreen: What data would you like to view?:
- Dropdown list of categories (from the database)
- Selecting Entry in dropdown leads to available information (from the database)
Any help would be appreciated, and of course thanks in advance.
the new (and pretty awesome) features of HTML5 is happening in the browser on the client side. What you will need is a back-end on the server side doing some magic. It is true that browsers now have databases but these are located on the phone, computer etc and as I understand your question you want these data to communicate with data on your server. To move data across the web you will need to perform HTTP-requests which can easily be done through javascript and ajax. Look a bit into these technologies and make a little server-side script that gathers data from the database and send it in a structured format to the phone (JSON, XML), then make a script in javascript on the client-side that parse these data and utilise them.
Good luck!