Lunarpages Web Hosting Forum

Author Topic: C# with MySQL, can it be done?  (Read 2113 times)

Offline iBlueVirus

  • Newbie
  • *
  • Posts: 4
C# with MySQL, can it be done?
« on: May 02, 2006, 08:26:54 AM »
I am trying to write a client application to access MySQL DB on my Lunarpages account.  But I can't seem to get a connection.  I am using System.Data.SqlClient and my connection string is in this format...

string source = "server=something.com;uid=username;pwd=1234;database=somethingDB";

Offline iBlueVirus

  • Newbie
  • *
  • Posts: 4
Re: C# with MySQL, can it be done?
« Reply #1 on: May 02, 2006, 09:21:36 AM »
I did a search and couldn't find anything...

I've tried with SqlConnection, OleDb, and MySQLDriverCS...  I saw one thread that someone was able to use MySQLDriverCS, so I guess it's possible.  I checked my Access Host under CP and it seems to be okay as well.  What am I missing?  Thanks!

Offline iBlueVirus

  • Newbie
  • *
  • Posts: 4
Re: C# with MySQL, can it be done?
« Reply #2 on: May 02, 2006, 09:42:07 AM »
btw, my try/catch exception is "SQL Server does not exist or access denied.".

I am accessing my DB with php and it's working.  As well as my username/password... :(

Offline GMTurner

  • Berserker Poster
  • *****
  • Posts: 7479
    • Turner's Lounge
Re: C# with MySQL, can it be done?
« Reply #3 on: May 02, 2006, 07:37:51 PM »
Just to make sure, have you added your IP (or the wildcard %) to the list of allowed hosts in cPanel?
The above information may or may not reflect current policy, opinions, or views since it was likely made almost 10 years ago.

Offline pgp_protector

  • Galactic Royalty
  • *****
  • Posts: 305
    • http://www.google.com
Re: C# with MySQL, can it be done?
« Reply #4 on: May 03, 2006, 07:39:28 AM »
You need to allow access from remote connections to your SQL Server.

By Default, Lunapages SQL servers are only accesable from Localhost.

Now if this application is going to be used from multiple sites (I.E. your going to use it at home, work, your frends house, ect and each one uses a diffrent provider) you may have better luck having your application access a PHP page on your server that then accesses the SQL Database.  Otherwise you're going to need to open so many diffrent wildcard connections that it's not funny, nor secure.


FYI If you in just the debuging stage you may find it easer to just run a local MySQL Server, and use that for development, then use the lunarpages MySQL server after you get your code working.

Offline iBlueVirus

  • Newbie
  • *
  • Posts: 4
Re: C# with MySQL, can it be done?
« Reply #5 on: May 03, 2006, 10:42:04 AM »
I did the specific IP and % thing and neither of them are working for me.  but as pgp_protector have suggested and I have thought of.  I think I am going to give it up due to security reason.  I'll just move back to PHP.  Thanks guys!

Offline mikemo

  • Spaceship Navigator
  • *****
  • Posts: 97
Re: C# with MySQL, can it be done?
« Reply #6 on: May 12, 2006, 07:49:18 PM »
definitely use the OLEdb classes - the system.data.sqlclient namespace is for accessing MS SQL Server.

the reason you can't connect is probably due to the fact that you have to explicitly define the address of the database server -- which does not reside on the same host as your web server.   contact technical support and they should be able to provide you the ip address to use to build the proper connection string.

hope that helps.