Can I access a remote Database through webservice? C# winforms - c#

Lately I asked this question regarding connecting my window app to a remote database (MySQL) hosted by some free hosting site. And I got "No way" answers.
How about using a webservice? Is it possible now?

Ok (and probably assuming .NET 4.0 on you hosting provider) this should be fairly straightforward:
Yes you can access data via a webservice.
If you want to with a minimum of effort you can use WCF Data Services
Not tried this but...
Create a web application
"Build" an entity framework model for your data (see Using MySQL with Entity Framework for linking EF to MySQL)
Create the data service (which seems mostly to be a matter of doing an add new item in visual studio)
Enable access to data service resources - i.e. change some code to make sure you can see what you need.
At this point you should end up with CRUD access to your database via a fairly comprehensive web service...
Biggest challenge there will be building the EF model - you really want a local instance of the MySQL database - schema at least - to develop against.

Yes if your webservice is hosted on same server which contains mysql database. You can locally connect to mysql using webservice (which hosting providers allow for sure) and can server data using the service.

Related

Moving app data layer from using Entity Framewok to use a Web API

Summary
I have an application which is built with WPF and EF6 (SQL Server Compact 4.0 database file).
The app is already deployed at customer site. The customer wants to migrate the local database to an online database.
Because it is not secure to connect remotely over the internet to my online mysql database, I used the open source PHP CRUD API and deployed it to my linux server.
The Problem
I have about 30 tables and thus models classes. Each table has more than 5 methods in its repository class.
Now when using API, I cannot directly use Entity Framework methods such as SaveChanges(), Add(), AddRange() etc... , instead, I'm using the model classes for the API and serializing/deserializing the model objects to Json and from Json.
This process requires a lot of work and time to migrate all 30 tables and rewrite all there related repository classes to get and set data from the API, taking into consideration the complexity of the entity relations.
Questions
Is this the correct way to migrate from local to online database ?
What is the most effective way to migrate an app with existing local database with EF 6 an online mysql database ?
"Because it is not secure to connect remotely over the internet to my online mysql database"
Why not? There are ways to secure an online database. You can host the db in the cloud, and securely open a port to only a range of ip addresses that the current customer has, or setup a vpn from the customer to the database.
If you must use a webapi you can put your ef layer under the webapi, and expose the webapi endpoints to the client for your crud methods. When you call the web api endpoint, you send the same models you have now, and the web api uses ef like it does in the thick client. You still have to secure the webapi endpoints to callers that you trust.

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.

MVC 3 C# - Deployment and MYSQL Database

Visual Studio 2010 - C# - MVC3
I am completely new to ASP.Net and I have been working / practising making an MVC 3 application using C#. I have practised getting an MVC application online which makes use of no databases and was successful. My hosting supports .net 4 and it was a simple process of publishing the files and uploading to my FTP. I am making a new application which makes use of a database. I have set up a data connection in the server explorer and set up all my tables and relationships. Everything is currently working as intended and I can create, edit and delete entries from the database.
I am not really sure where to start with getting this online. My hosting offers no MSSQL databases so I am presuming I can use a MYSQL database? What is the process of changing my application to use a MYSQL database which is located on my remote hosting? Also I am making use of the default accounts where users can register and login, will I have to set up a database for this too?
Your host offers mysql hosting?
you will need the mysql .net connectors.
also check this next out for the asp.net membership, mvc uses
http://dev.mysql.com/doc/refman/5.1/en/connector-net-tutorials-asp-roles.html
You can use a local DB in your APP_DATA folder or you can connect to a remote DB. Please let me know if you need additional help in either of these two areas or if I have misunderstood your question. You may also want to encrypt your web.config file to secure your DB passwords better.
From our chat:
Try this stackoverflow.com/questions/…
SQL CE supports binary deployment, meaning your hosted doesn't have to have anything installed and you get SQL support, however no stored procedure support (if that matters to you here)
In addition you can install the SQL Compact Toolbox into Visual Studio
http://sqlcetoolbox.codeplex.com/
See: http://blogs.msdn.com/b/webdev/archive/2011/01/06/how-to-bin-deploy-sql-compact-edition-4-0-and-razor-web-projects.aspx

Technique(s) in a C# multiuser application where all clients have their data up-to-date from a central database

In a multiuser environment:
How do you make sure that all clients see eachothers changes? What is the best way to do this?
In the past I created a C# application and installed it on 2 pc's. It connected to a central SQL Express server (the client application worked with Entity Framework Code First as ORM).
When client1 added a record to the database, this was not directly visibly to client2. Only if client2 fetched all data again (hard refresh) the change was visible.
Now I am looking for a solution on how this 'sync'(?) can or should be done. I like working Entity Framework Code First, it would be nice a solution could keep this.
Also the application is still in a very early stage.
I thought by having a central database and multiple clients connecting to it, but I'm not sure if this is a good solution. If your suggestions/solutions would require a central server application where the clients connect to (and where the server application does the database handling) this would be no problem.
If possible a basic sample solution or some basic code that shows how to always work with the latest data could would be very helpful!
Similar questions:
Entity Framework - Underlying data (in database) change notification
Entity Framework data updates in a multi-user environment with central database
Entity framework data context not in sync with database?
Thanks in advance
It depends on your environment and the data you are managing and the architecture you want.
If it's OK/acceptable to let clients have copies of the data which they can work with, they need to work with the data when not connected to the central server, then you could use the the Sync Framework.
You'd have your central SQL Server as usual, and use the Sync Framework to sync with clients.
You would write a "Provider" which would decide how to resolve changes made to the same data by different clients, etc.
You would have to put SQL Express (or possibly LocalDB (new name for SQLCE)) onto the client machines.
Then do your Entity Framework Model/Code to access the local database instead of a central one.
http://blogs.msdn.com/b/sync/archive/2008/06/24/sample-sql-express-client-synchronization-using-sync-services-for-ado-net.aspx
Otherwise it's down to designing and implementing some "tiers" and following a Distributed Internet/Database Architecture/SOA.
A nice free resource:
http://msdn.microsoft.com/en-us/library/ff650706.aspx
http://mtechsoa2011.blogspot.co.uk/2011/04/soa-vs-distributed-internet_27.html
Some useful books:
http://www.amazon.co.uk/Service-Oriented-Architecture-Concepts-Technology-Computing/dp/0131858580/ref=sr_1_1?s=books&ie=UTF8&qid=1343295432&sr=1-1
Other solution is create an "interface" for your database and each put data operation from some client can notify other clients. You can implement such interface by WCF with it's callbacks.
I have no simple code for whole architecture solution... If you'll ask more concrete question about building n-tier application with WCF I'll try to help.

Accessing remote MySQL data using c#

I work on a Joomla web site, installed on a MySQL database and running on IIS7. It's all working fine.
I now need to add functionality that lets (Joomla-)registered users change some configuration data. Though I haven't done this yet, it looks straightforward enough to do with Joomla. The data is private so all external access will be done through HTTPS.
I also need an existing c# program, running on another machine, to read that configuration data. Sure enough, this data access needs to be as fast as possible. The data will be small (and filtered by query), but the latency should be kept to a minimum. A short-term, client-side cache (less than a minute, in case a user updates his configuration data) seems like a good idea.
I have done practically zero database/asp programming so far, so what's the best way of doing that last step? Should the c# program access the database 'directly' (using what? LINQ?) or setup some sort of Facade (SOAP?) service? If a service should be used, should it be done through Joomla or with ASP on IIS?
Thanks
I ended up using a WCF service façade written in c# that returns the data from the database. The service only exposes a couple of functions that query parameters as arguments. The SQL queries are not exposed, nor is the database connection string. The WCF service uses the mysql connector/net 6.3.1 to talk to mysql. The WCF service is accessible only over https, and requires a username & password.

Categories