C# Use/connect to MySQL database in webhost (One.com) - c#

I want to connect to my one.com webhost, by using my C# winforms application. The support said extern connections is NOT allowed, then how am I gonna read the database table on my webhost? I was told that if I used PHP on the website, then it would work, and it does. But how should i access that code from my program and make it return some values?
Any help will be appreciated. thanks in advance.
PS. If i'm unclear somewhere, or if you need more information then just explain what's needed.

Your webhost has probably restricted the access to your database so that only a specific host can connect to it, namely the one hosting your PHP based website. This is a common practice.
If this is the case, you cannot connect from any other host - and thus, your C# winforms app won't be able to connect either.
So a direct connection from your C# app to your database isn't an option, but you might implement a REST interface with PHP that serves the data you need to the outside world. This could then be accessed by the clients using your C# app. This is the only solution I can think of.

Related

Web service for Laravel

Assume that I have a third-party database application with SDK that can be used to retrieve data out of the database in XML.
On the other side, I have developed a website using Laravel framework of PHP. The website is supposed to display data from the database of the application.
In regards to above I have the following questions:
As far as I understand, I can either store the requested data in my website database or just show it without storing. What technique do you suggest?
How do I achieve xml data transfer from the database server to the website?
Taking into account that I have experience of development in C#, I assume that I have to develop some web-service that would run on the database server, retrieve the required data and send it to my website. So the web-service has to receive the requests from my Laravel website, retrieve data from database server accordingly and pass the xml response to my website that would finally display it. Am I on the right way? If so, could you please guide me on how to code and bind these parts?
Thank you in advance.
I have to agree with #Serge in the comments - there are many ways to do this because it is a very broad question.
My answer was mostly going to deal with how regularly the third party database was going to be updated but judging from your comments, I'm assuming it will be fairly often? In which case, I would likely connect directly to the third party database from your laravel app using the firebird driver found here: https://github.com/jacquestvanzuydam/laravel-firebird (Please note, I have never used this so I cannot comment on it's quality) instead of writing a C# web service. I don't know much about firebird itself but you will likely want to connect using an SSH tunnel or VPN for security reasons.
Then I would either store data in MySQL if you know it isn't likely to change very often (in this case you would use a laravel command, run on a schedule, to pull data out of firebird every [X] days/hours/minutes depending on the data) or, if the data is likely to change on each potential web request, using some form of caching system (redis, memcache, file cache etc) to speed up the web requests.
Sorry if that isn't particularly helpful - if you can provide more information maybe I can help you out further :)
Good luck!

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

Connecting C# Back-end with PHP frontend

I have a code written in C# I would like to use as the back-end of a site I'm building.
I would prefer not to build the site front-end in ASP.NET (which integrates nicely with C#), and to use PHP or Python instead.
Is that reasonable? Should I re-consider using ASP.NET?
How can I achieve that?
Just use asp.net mvc framework for the frontend instead of plain asp.net. It's easy to learn. And if you know php it will be easy to you undestand asp.net mvc.
I don't see the reasons if you are using c# backend use php frontend. For sure you can create service layer on c# and communicate with php through it, but it does not make sence for me.
You can do whatever you like. Personally i wouldnt use php because i dont know very much php.
But you can do it, you could expose a soap web service and there are libraries that will let php talk to it.
No one here will be able to tell you what you haven't already told us. Asp.Net will probably be easier because of how everything integrates and you can share classes etc - but that does not mean you HAVE to use it.
Both of them are fairly passive server side technologies that present html to browsers though. why do you need 2 servers?
You have to ask why you are doing it .. if you are playing and want to learn then of course you can do it just to see how it all works. But if you are on a commercial project then id suggest that you dont need both a php and a c# server ... or if you do perhaps you want to go asp.net for your web server and if you need another layer of services behind then use WCF if you want to go a microsoft route. Howver it is usually possible to host all services in the same IIs instance.
You can do this i have done this for a web site my self use a database server or files,
http://dtpgroup.co.uk/
Your C# application can connection to your store save the info it needs to then php can read them if it file just use a formatted file E.G
if your using Database php can connect to MySQL or MSSQL so your C# application can use MySQL if you know what your doing in C# if not and your more comfortable in php then use MSSQL (also php have the superior documentation )
I work in both frequently
Ugh, in normal instances, reading data with C# writing it to files and loading up with PHP sound slow, inefficient and down wright crazy. I believe these terms are being used wrongly.
Client Server - user machine - database great for private networks where you connect to the DB without going over the internet
vs n-Tier
Client - Browser programming html, css, javascript connects to middleware over the internet
Middleware - inside your firewall, connects browser to database could be called part of backend - php and C# are middleware languages
Database final (generally 3rd) tier
With php and c# you are creating multiple middleware layers
why why why would you do this for a web app pick one
now if you have a web app with PHP and sneakerware in house client server apps that are controlled ie shipping, accounting that are not exposed - maybe but you have added complexity that you would not need (generally)
Gary

C# connections to mySQL || Retrieving Data From A C# Program Via A Browser

I am building a C# program for a company that eventually will store information about newspaper articles in a data structure. The key here is that they want to be able to query this data structure via a browser remotely, so the obvious choice I suppose therefore would be using something like SQL. So I have two questions:
If I use SQL how could I store results from the C# program as it runs to the SQL database? Would this involve opening up a connection inside the program akin to the mySQL command line console?
Is there an alternate way, i.e. where I could store the data inside the C# program solely that is running on the server, and query this for results via a web browser just as I would if I were using SQL?
Many thanks for your advice
you can communicate with an SQL server with C# ... It's pretty easy, lots of examples out there.
It would be better to use an SQL server. Using an internal database will mean you will have to implement a database mechanism that will be robust against crashes. SQL already is.
You can implement it easily by using ASP.Net (For accessing with a web browser).
Or look into WCF or web services if you want to implement your own browser. WCF or web services will give you tools to create a simple-to-use API that acts as a server.

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