I want to connect to an online SQL database. to do that, I use this code:
SqlConnection conn = new SqlConnection("Data Source=77.243.225.193;User ID=rune;Password=secret;database=test");
conn.Open();
Textbox.Text = "ServerVersion: " + conn.ServerVersion.ToString() + "\n\r";
Textbox.Text = "State: " + conn.State.ToString();
I just got the code from the internet, since this is my first time using this.
Somehow this does not work because it says that it can’t connect to the database. Can anyone explain me why?
Thanks!
Run throug a series of tests and check off the ones that past:
testa valid name of a database that is online and mounted on the server?runea valid SQL login for the server?runehave the appropriate permissions to access thetestdatabase?There are obviously a myriad of reasons why you might not be able to connect, what exact error message are you getting?
UPDATE: based on your last comment, you saying you use phpMyAdmin… Which is a management tool for MySql databases (someone correct me if I am wrong)?
If it is a MySql database, you need to be using MySql ADO.NET Connector along with a valid MySql connection string. Check http://www.mysql.com/products/connector/