namespace sqlconnecttest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            SqlConnection myConnection = new SqlConnection("user id=name" +
                                       "password=pass;server=http://www.mywebsite.co.uk;" +
                                       "Trusted_Connection=yes;" +
                                       "database=mydb; " +
                                       "connection timeout=30");
            try
            {
                myConnection.Open();
            }
            catch (Exception f)
            {
                MessageBox.Show(f.ToString());
            }

        }
    }
}

The messagebox always shows, with a massive error string in it, about it not being found.

I'm usualll doing something fundamentally wrong.
I'd appreciate any hints.

edit. sorry but the code came out all wierd.

Edited 6 Years Ago by Suzie999: n/a

What the error is coming up ? In Server you need to place address of your database server and you have set it with some website address.

namespace sqlconnecttest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            SqlConnection myConnection = new SqlConnection("user id=name" +
                                       "password=pass;server=http://www.mywebsite.co.uk;" +
                                       "Trusted_Connection=yes;" +
                                       "database=mydb; " +
                                       "connection timeout=30");
            try
            {
                myConnection.Open();
            }
            catch (Exception f)
            {
                MessageBox.Show(f.ToString());
            }

        }
    }
}

The messagebox always shows, with a massive error string in it, about it not being found.

I'm usualll doing something fundamentally wrong.
I'd appreciate any hints.

edit. sorry but the code came out all wierd.

Well thats most of my problem, I dont know what else to put there.

Therror I get is an mysqlclient exception Cannot connect to database make sure its configured to accept remote connections (My ip has been entered into the mysql remote host list in cpanel)

I'm baffled by it all, I have a name server, and when I replace my domain address with it, the outcome is the same.

Well set "Server = IP you had entered into the mysql remote host list in cpanel" not any website address..

Well thats most of my problem, I dont know what else to put there.

Therror I get is an mysqlclient exception Cannot connect to database make sure its configured to accept remote connections (My ip has been entered into the mysql remote host list in cpanel)

I'm baffled by it all, I have a name server, and when I replace my domain address with it, the outcome is the same.

My ip has been entered into the mysql remote host list in cpanel

The SQL server is set up where? On your machine? Remotely at some hosting provider? At the corner store down the street?

If it's set up on your machine then I hope to god you've got a non-dynamic IP address... if so just put the IP address of your machine where you have server= ...

If it's set up at some hosting provider, they should have information for you to know the specific location of the SQL server path as it would be accessed remotely. Generally this would equate to a longish URL/subpath combination specific to an address configured to your particular account node on their SQL server. Most web-host providers will have a link in their SQL server configuration section to show the specific location/URL for your server connection that you can copy to your program. Some even go so far as to provide an entire connection string.

If none of this helps, please post the actual error you're receiving so we can see better what the problem is :)

Hope this helps. Please don't forget to mark your thread solved once the issue is resolved.

Thank you for your reply Lusiphur.

Its on a web host server (a free one at that) so I paid up for a host prper to see if that made a difference, (It did'nt)

I've tried the server name, the server IP address, my cpanel usaername and password, database username and password, my IP in remote connection list, % in same, etc...

I've read thread after thread across the internet.

I've come to the conclusion that I must be doing something wrong at basic ground level, but I just cannot put my finger on it.

I tried for 2 weeks before posting for help, and my project was at a stand still.

I worked around the problem by doing the job via a txt file on the internet, and it works and suits me fine. Except I personally have to overcome this obsticle, its winding me up.

I dont meen to hurt anyone, I have followed so many examples in the help and snippets forums, here and elsewhere, and I'm coming up blank.

The error is huge string in my messagebox.

[IMG]http://img.photobucket.com/albums/v438/qaz/errorsql.jpg[/IMG]

This article has been dead for over six months. Start a new discussion instead.