0

I have an application that I created in C# WinForms. I also have a MySQL database, which is not publicly accessible (only from related webhosting) - so no MySQL Connector available.

What I did is, that I send data from C# via POST method to PHP and PHP code execute my SQL queries. In case of SELECT query - PHP returns result in JSON string, which I deserialize in C# through some JSON DESERIALIZING extension.

I want to do the same app in C# WPF and later on with ASP.NET and maybe some PHP/JS(REACT) to train my knowledge with these platforms/languages/frameworks...

Which means - I would like to ask you, what do you think is the best way, to create the communication either for C# WinForm/WPF to MySQL and ASP.NET to MySQL?

I did some small research and found some technologies like: RESTful and SOAP. There are many others I believe, but I don't know which one I should really focus on. Which is the best for now and future? It doesn't matter how hard is to learn the technology! So "this is the simplest solution for your small app" is not the proper solution i am looking for as I am going to do larger apps in future and I want to focus on the best available technology,

Ask for more if needed.

Thanks.

3
  • There rarely is a 'best' solution to something regardless of centext. It pretty mush always depend on what you want to achieve. Commented Oct 16, 2018 at 11:21
  • It depends on what all options you have to connect to given database. Commented Oct 16, 2018 at 11:23
  • There's a downloadable Connector/Net assembly to let C# programs send queries directly to MySQL and get result sets back. Check it out. Commented Oct 16, 2018 at 11:47

1 Answer 1

1

There is only ONE way to do that - which is using ADO.NET DbConnection subclasses that are provided by the MySQL package.

Which you can find at.... https://dev.mysql.com/downloads/connector/net/

for the oddicial one. There are alternatives, paid and free.

Now, some will say "what about dapper" or "what about entity framework".

WRONG QUESTION. See, both of those, and all other ORMs - use the ADO.NET DbConnection subclasses internally to CONNECT. THey pack them up in nicer (better) API's, but that is explicitly NOT the question here.

Now:

I did some small research and found some technologies like: RESTful and SOAP

BAD research. Both REST and SOAP are NOT TOOLS FOR THE QUESTIOn. They are tools on how to expose an ASP.NET API so other things can connect to it - they do not talk about where the data comes from.

Sign up to request clarification or add additional context in comments.

3 Comments

I cannot use MySQL connector. The database is not accessible publicly. So as I did now - I access to PHP files which are stored on FTP of the webhosting where is the MySQL database. Can’t go directly to MySQL - so I have to use PHP files or something else - if there is any other option..?
That may well be, but that is NOT THE QUESITON YOU ASK. I answer the question you ask.
1) Read end of the second row of my post. -> so no MySQL Connector available! -> means, I asked for other solution. 2) SOAP is not a tool for this question? -> Why I just did SOAP Web Service and using its PHP functions in C# as classes and everything works fine. Anyway for anyone who is interested - SOAP is a really great and simple technology how to connect C# to MySQL when you cannot use MySQL CONNECTOR. You just write some function in PHP, call this PHP in Visual Studio as Reference and then it works as ordinary classes in C#.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.