Wednesday, March 28, 2012

no external connections are permitted while trying to connect to SQL server

ok so this is my code:

private void iDListBox_SelectedIndexChanged(object sender, EventArgs e)

{

string connectionString = GetConnectionString();

using (SqlConnection connection = new SqlConnection(connectionString))

{

SqlCommand cmd = new SqlCommand("SELECT * FROM Table1 WHERE Naam=@.Naam", connection);

cmd.Parameters.AddWithValue("@.Naam", iDListBox.SelectedValue);

connection.Open();

SqlDataReader reader = cmd.ExecuteReader();

if (reader.Read())

{

naamTextBox.Text = reader.GetString(1);

}

reader.Dispose();

connection.Dispose();

}

}

static private string GetConnectionString()

{

return "Data Source=(local);Initial Catalog=AdventureWorks;"

+ "Integrated Security=SSPI;";

}

but when I change the selected index of the listbox, then this error comes up:

System.Data.SqlClient.SqlException was unhandled
Message="An error occured while setting up a connection with the server. At making a connection with SQL server 2005, this jamming is possibly caused by the fact that at the standardinstitutions of SQL server no external connections have been permitted (provider: Provider of named pipes, error: 40 - no connection with SQL could open server)"

If the error sounds a bit weird, sry I tried to translate as most of my errors come in my language

someone knows what the problem is and a solution to it?

(btw sry if this is in the wrong part of the sql forum, but there are so much parts, I didn't know which to choose lol Stick out tongue)

thx in advance

Please see http://blogs.msdn.com/sql_protocols/archive/2007/03/31/named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server.aspx to see if any of the suggestions solves your case.

Jimmy

No comments:

Post a Comment