PDA

View Full Version : سوال: علت خطای A network-related or instance-specific error occurred



mrmaleki
پنج شنبه 04 اردیبهشت 1393, 20:24 عصر
سلام کد پایین و برای کانکت کردن کردن دیتابیس به گرید ویو نوشتم ConnectionString هم از روی پروپرتی دیتابیسم وارد کردم اما نمیدونم چرا موقع اجرا اکسپشن زیر رو میده و میگه
سرور غیر قابل دسترس

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)



private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = bindingSource1;
GetData("select * from CustomerGeneralInfoSet");
}


private void GetData(string selectCommand)
{
try
{
String connectionString =
"Data Source=(localdb)\v11.0;Initial Catalog=CustomerGeneralInfo;" +
"Integrated Security=True";


dataAdapter = new SqlDataAdapter(selectCommand, connectionString);


SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);


DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
bindingSource1.DataSource = table;


dataGridView1.AutoResizeColumns(
DataGridViewAutoSizeColumnsMode.AllCellsExceptHead er);
}
catch (SqlException e)
{
MessageBox.Show(e.Message);
}
}