Pregunta

I am have tremendous trouble with this.

What I want to do is: I want to create a system (in C#) that will (amongst other things) allow users to send simple messages to each other. So I want to create a MySQL database which will rest on a server. Other computers running the system will then have to connect remotely to this database and read a certain table to see if they have any new messages. I want the client computer to connect via the internet to the database on the server.

But how do I do this?

  1. How do I create a database that can be connected to through the internet?
  2. How should my connection string look like on the client computer?
  3. What configurations do I need to do on both client and server computers?

Any assistance is deeply appreciated, and if you could suggest how I can go about achieving my objective. I am a quite competent programmer, but HATE these network things!

I am developing in C# using WPF to access the database. So it's a desktop app!

¿Fue útil?

Solución

Here's how you do what you're asking to do.

Use the MySQL Connector/NET ADO.NET connector. It is here. http://dev.mysql.com/downloads/connector/net/5.1.html

Follow the directions for setting it up. It works very well.

Put your MySQL server on a public IP address.

Get your client software assembly to connect to that public IP through the ADO.NET connector.

But, PLEASE!

Ask yourself whether this is the right thing to do. It probably isn't, because MySQL servers (and all table servers) work much more safely and predictably when they are behind firewalls and accept connections from a limited number of client packages.

Consider doing what Mike Christensen suggested. Use ASP.NET and WCF, or whatever stack you like, to build a server-resident interface to your MySQL database. That server-resident interface can then be accessed by the client software you push out to your end users.

That interface can have just the methods you need. WCF or any other stack for building server components can do this easily and robustly. For example.

Client 1: This is moe. Here's a message for curly:  "Look at the grouse, look at the grouse".
Server: OK

Client 2: This is curly: any new messages?
Server: moe says "Look at the grouse, look at the grouse".

Client 1: This is moe. When did curly last collect my messages?
Server: ten minutes ago.

Client 2: This curly. any new messages?
Server: NO

This is far safer and more scalable than just making the MySQL interface available on the internet, and it will perform much better.

By the way, it looks like you want an instant messaging protocol. You may want to look into using the open-source system at http://jabber.org . This stuff can be tricky to get right if you build it all yourself.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top