Connecting to a database remotely through VS2005

A

axel22

Ok, I've installed MS Sql Server Express, and I've created a database
'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();
}
 
C

Cowboy \(Gregory A. Beamer\)

Make sure you have a protocol to connect other than Shared Memory using the
config tool.

You may also have to turn on SQL Browser
 
B

bruce barker \(sqlwork.com\)

by default sqlexpress does not allow tcp/ip connects, only local shared
pipes.

-- bruce (sqlwork.com)
 
A

axel22

Already enabled shared memory and named pipes.

As for the link, thnx, i'll look into it!


Juan T. Llibre je napisao/la:
Please follow the procedure outlined here :
http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

Doing that will fix your problem.




Ok, I've installed MS Sql Server Express, and I've created a database
'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();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top