|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Connecting to a database remotely through VS2005'ProbnaBaza' and a table 'clan' in Management Studio. I tried using the database locally through a project in Visual Studio. I used the following connection string: "Server=.\\SQLEXPRESS;Initial Catalog=clan;Integrated Security=SSPI"; It worked perfectly. Then, I tried using the database by setting an IP address within the connectionString, but only to be given an error message: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) Can anyone help? Here is my source: SqlConnection conn = null; private void Form1_Load(object sender, EventArgs e) { conn = new SqlConnection(); conn.ConnectionString = "Data Source=89.172.48.15,1433;" + "Initial Catalog=clan;Trusted_Connection=False;"; } private void button1_Click(object sender, EventArgs e) { conn.Open(); SqlCommand comm = new SqlCommand("SELECT * FROM clan;", conn); SqlDataReader reader = comm.ExecuteReader(); while (reader.Read()) { label1.Text += reader[0].ToString() + reader[1].ToString() + reader[2].ToString() + '\n'; } conn.Close(); } |
|||||||||||||||||||||||