SQL Server 2005 Express Edition에 C#을 사용하여 원격으로 연결하려고하지만 예외가 발생합니다. 다음은 원격으로 C#을 사용하여 SQL Server 2005 Express에 연결할 수 없습니다.
내가 데이터베이스A network related or instance specific error occured while establishing a connection to SQL Server .The server was not found or was not accessible.Verify that the instance name is correct and the SQL Server is configured to allow remote connection. (provider :Name Pipes Provider,error:40 - Could not open a connection to SQL Server)
private void button_test_Click(object sender, EventArgs e)
{
try
{
string str = "data source=" + textBox_server.Text + "; initial catalog=" + textBox_db.Text
+ "; user id=" + textBox_user.Text + "; pwd=" + textBox_password.Text + ";";
SqlConnection sqlcon = new SqlConnection(str);
sqlcon.Open();
sqlcon.Close();
MessageBox.Show("Test Connection was successfull");
}
catch (Exception ex)
{
MessageBox.Show("Test Connection failed. "+ ex.Message);
}
내가 올바른 IP, 데이터베이스 테이블 이름, 사용자 이름과 암호를 입력하고 연결하기 위해 사용하고있는 코드입니다.
SQL Server Express 구성의 모든 항목을 확인했습니다. 모든 것이 좋습니다.
그래서 나는 어디로 잘못 가고 있습니까?
독립형 PC에 SQL 서버가 "TCP/IP"
방탄복의 속성을 편집? 그렇다면 특정 포트를 열어야 할 수도 있습니다. – Derek
방화벽을 언급하지 않으면 연결을 허용하도록 Windows 방화벽을 구성해야합니다 (SQL Express가 실행되는 PC에서) –
나중에 두 PC 용 Windows 방화벽을 구성했습니다. – Sohail