Connecting to MySQL

Connecting to MySQL server not on local machine

Page 1 of 1

5 Replies - 771 Views - Last Post: 30 April 2010 - 11:55 PM Rate Topic: -----

#1 efficacious  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 09-November 09

Connecting to MySQL

Posted 28 April 2010 - 01:51 PM

Hi friends,

I am working on a application in Visual C# 2010.
I've been trying to connect to my MySql Database that I have located on another machine on my network.
The database is setup properly as I have other web apps that use it but they are located on the server machine.

But like I said I"m having difficulty getting connected.

The code used to connect:

            //Initilize DataSource Variable
            string DataSource;

            //Construct the Database connection string
            DataSource = "Data Source=" + DbHost + ";Port=" + DbPort + ";Database=" + DbName + ";User ID=" + DbUser + ";Password=" + DbPass + ";";

            //Create Connection Object
            MySqlConnection MySqlCon = new MySqlConnection(DataSource);

            try
            {
                MySqlCon.Open();
            }
            catch
            {
                return false;
            }

            return true;



I've been giving my domain name in this format:
mydomain.com

i've specified port and my ports are open
I just can't crack it..sigh

Any suggestions are most welcome thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Connecting to MySQL

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1632
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Connecting to MySQL

Posted 28 April 2010 - 01:56 PM

You getting errors? What's happening?
Was This Post Helpful? 0
  • +
  • -

#3 efficacious  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 09-November 09

Re: Connecting to MySQL

Posted 28 April 2010 - 02:11 PM

View PostPsychoCoder, on 28 April 2010 - 12:56 PM, said:

You getting errors? What's happening?



I'm not sure I'm just using try/catch to pick up if it fails or not.
Could it be cause i'm using debugger? or should it still work?

This post has been edited by efficacious: 28 April 2010 - 02:14 PM

Was This Post Helpful? 0
  • +
  • -

#4 efficacious  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 09-November 09

Re: Connecting to MySQL

Posted 28 April 2010 - 02:31 PM

View Postefficacious, on 28 April 2010 - 01:11 PM, said:

View PostPsychoCoder, on 28 April 2010 - 12:56 PM, said:

You getting errors? What's happening?



I'm not sure I'm just using try/catch to pick up if it fails or not.
Could it be cause i'm using debugger? or should it still work?



i removed the try/catch statements and am now getting an error destription from the debugger
saying that I am not allowed access.

Is this not something that can be done? Or is this an SQL issue?

I would based on that error go and set permission on my database however I haven't created one yet and I am trying to do so from the application. I have even tried the root username and password for the SQL server and it still won't allow access..

This post has been edited by efficacious: 28 April 2010 - 02:37 PM

Was This Post Helpful? 0
  • +
  • -

#5 efficacious  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 09-November 09

Re: Connecting to MySQL

Posted 30 April 2010 - 11:25 PM

View Postefficacious, on 28 April 2010 - 01:31 PM, said:

View Postefficacious, on 28 April 2010 - 01:11 PM, said:

View PostPsychoCoder, on 28 April 2010 - 12:56 PM, said:

You getting errors? What's happening?



I'm not sure I'm just using try/catch to pick up if it fails or not.
Could it be cause i'm using debugger? or should it still work?



i removed the try/catch statements and am now getting an error destription from the debugger
saying that I am not allowed access.

Is this not something that can be done? Or is this an SQL issue?

I would based on that error go and set permission on my database however I haven't created one yet and I am trying to do so from the application. I have even tried the root username and password for the SQL server and it still won't allow access..



Can any1 help with this I'm having the dangedest time.
I have even tried creating a db and setting permissions and I still can't connect.

This post has been edited by efficacious: 30 April 2010 - 11:27 PM

Was This Post Helpful? 0
  • +
  • -

#6 efficacious  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 09-November 09

Re: Connecting to MySQL

Posted 30 April 2010 - 11:55 PM

Nvm this is solved..

I figured out the issue..

its was a indexing mix up just had to switch some numbers.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1