C# WP8 Connect to MySql database - c#

I am struggling to figure out how to connect to a MySql database in my C# Windows Phone 8 application like I can on my desktop application. The reason I am struggling is because it seems I cannot just use the same MySql.Data library that I used on my desktop application. Are there any other libraries that I can use to access my database?
PS. I really don't want to go the PHP route because I will have to have Apache running on y server two and will have to add JSON interfacing two which will not only be a hassle but possibly also waste some processing time and make my application more complex.
PPS. If not possible with MySql, can it be made to work with Microsoft SQL Server or Azure?
EDIT:
If some sort of HTTP interface is my only option, is there some easy existing API or something that I can use to allow SQL data transmission or will I have to create specific PHP(/asp.net or whatever) code for each type request that I am planning to send?

Related

Connect to MS Access Database with android

I'm working on a project and I need to connect to MS Access Database. The problem is that I'm using a pretty new platform , I'm using Visual Studio 2015 Xamarin and I'm developing to android with c# (thought this platform).
I already have a project with this Database using aspx and i need to connect the android application to this Database .
I could not find any answer for it , probably cause it's new .
Thanks for helping.
The problem is not related only to Xamarin or MS Access.
Everytime you want to use the same database in different applications (in your case a website and mobile apps), it is better to create a new layer (WCF Service or REST API) in order to access the same database on the server. This is more flexible and would be the right thing in your case.
Without moving the architecture to the next Level, you will always have such problems when mixing old and new technologies together.
If you just want to finish this quickly for school and use the database only on the device, then there is no way to use the MS Access database with xamarin. I recommend using SQL lite for this and there are lots of examples for that:
https://developer.xamarin.com/recipes/android/data/databases/sqlite/
It not clear if the database is to run “local” on the android, or you just wishing to connect to some web service that holds the database?
If you needing a local database to run 100% stand-alone on the Android device, then Access is not supported. Your best bet for a local database would thus be SQLite.
Perhaps you don’t need nor want a local data store. In this case if the Access database is on the server, then you would be forced to write some kind of web service to “interact” with your Android software and the web server (this would not be a "general" interface to the database, but a set of web services that you expose on the web site - this assumes you thus have control and are able to write software and implement a web service on the web site. So in this case some kind of “direct” connection to the Access database is not possible.
You could again certainly DIRECTLY connect to a server based database like SQL server – but this would assume the web hosting allows external ODBC connections to the database (often they don’t allow this, but some do).
So not clear is if you need a local database running on the Android that can THEN connect to some web or server based system, or you simply want the android to connect via the internet to some database hosted on some server and the Android device does not have a local database at all.
Regardless of the location of MSAccess, you cannot "connect" to a non server database like Access. So the question remains as to "where" you want this database to be used, and ALSO if you need a local data store on the Android device or not.

C# silverlight application server

I am building an application that needs to connect to a server to send and retrieve data constantly.
at first i was going to use mysql, by mysql is far from what i want. using this would force users to connect to the database constantly.
CAN C# silverlight connect to a server and send a message?
here is an example to something in C# console, VERY similar to what i am trying to achieve
https://www.youtube.com/watch?v=9kcrTKj7Jpk
Any documentation would also be helpful.
To be more specific my server will be written with C# console, but i want my c# silverlight to send the message.
Yes.
CAN C# silverlight connect to a server and send a message?
Traditionally, the way that Silverlight has connected to a server to send a message is with WCF services. This still works well, but the other option is REST.
What you will need to do is write a layer (or use an ORM like Entity Framework) to persist data from whichever database platform you choose (MySQL or otherwise). Then you will need to write REST, or WCF services on top of this. You will then need to consume the services from your Silverlight application.
There are many articles on this if you Google. Here is one of the ones that comes up instantly:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=228
One thing you must consider with Silverlight, is that by default, Silverlight will only talk to the server that the Xap package is hosted on. So, if you need the Silverlight app to talk to a different server, you will need to set up and expose a clientaccesspolixy.xml from the server where the WCF/REST services are hosted. This is a stupid limitation that Microsoft made a big mistake on in the first place. Here is an article about it:
https://msdn.microsoft.com/fr-fr/library/cc197955(v=vs.95).aspx

.NET Compact Framework - SQL Server Compact or Flat File as backup

I've got a question regarding the pros and cons of using a database vs. a flat file in a windows mobile application.
We're developing a mobile application running on Windows Mobile 6.5 and using C#/.NET Compact Framework 3.5.
The mobile component is used in an inventory system to do receiving of deliveries. These data are then sent to the application server using a web service via Wi-Fi.
Now, we need to implement a backup plan. What we agreed so far is when then the mobile is unable to send the data to the server, it has to persist it locally and then send it at a later time. It can either be sent using the mobile or the mobile can be docked/connected to a PC via usb which will pull the data out and the PC can send it to the server.
My question: which is better to use in this scenario? Deploying an SQL Server Compact or writing the data to a flat file (xml, binary etc)
I'd like to get opinions on the pros and cons of each method keeping in mind not only the technical aspects but also the development work involved.
Thanks!
My personal experience with this scenario is to use SQL CE to do Merge Replication instead of a web
service for some very good reasons:
Your application becomes easier to develop because you read/write directly to a database and let the CE engine do the merging. (Linq to Sql etc)
You can manually control merge conflicts at the server or client. And this is already built, you don't have to build it yourself.
There is no backup necessary because your data on the CE device is already in a database.
Data can be cached locally as needed and filtered by device or user (meaning only the data needed by the device/user can be the replicated to the device.)
Although this does require more SQL knowledge, it is solid technology that works, and doesn't have to be re-written, tested and debugged continously.
If you are locked into using a web-service, then using SQL CE seems like overkill to me. I would simply duplicate what a database does and write transactions to a file (xml/json/binary) and then use those as needed (running them against the web-service when in wi-fi range or having a service running on a machine that pulls the files off the mobile device and onto the local PC or server and running those transactions).

using MySQL with C#

I want to know if it is possible to use MySQL Engine without having to install WAMP Server. I'm developing an application that will require a database, so I was thinking of using MySQL instead of MS SQL or access. So I don't want to install the WAMP package yet I want to install the MySQL Engine, so if possible, please provide me with the download link for the MySQL and how to install and use (start/stop service).
You will need the runtime and the .net connector to make this happen. You also might find the workbench (gui tools to manage the server and run queries) to be helpful.
The runtime installs a service by default, which you can control on the commandline or via the windows service management console (services.msc).
This sounds to me a lot like you're thinking 'desktop application', where the MySQL database will be a simple local data store. If that's the case, MySQL is not a good choice.
MySQL is a server-class database engine. It's designed to run full time in the background as a service. This makes it overkill for a simple desktop app, and as a user I'd be mad if your simple desktop app required me to run the MySQL service.
For the kind of app I think you're building, you really want an in-process or desktop-class database. Good examples include SQLite, SQL Server Compact Edition (not Express), or even MS Access. Any of those would be a better option here than MySQL.
On the other hand, if I'm wrong and you're building a web app or an app that will be distributed to several computers that all share the same database, then MySQL is a perfectly fine choice and you should read #Femaref's answer.
If your database isn't going to be incredibly large you could go with SQL Compact. It comes with the .NET framework, and works well for smaller databases.

Grabbing MS SQL Server Data for iPhone App?

I have a pre-existing desktop application that draws its information from a Microsoft SQL Server. The desktop application is written in C#/ASP/.NET.
I'd like to take this same data and present it in an iPhone application. What would be the best way to obtain and present the data?
I would recommend writing a web service that exposes the data and then interfacing with this from the iPhone across the network.
Calling web services and making HTTP calls is very easy on the iPhone.
Do you assume your iPhone application will have network access? If so I would go the webservice route as already mentioned. If it's a small database that you want available on the iPhone with out the need to access the internet to retrieve data you could look at converting the SQL Server database into a SQLite database and packaging it with your app.

Categories