用SQL Server2008建立的数据库用VS2008建立了一个项目项目中能实现表中数据的插入操作但是在执行表中数据删除操作时出现在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。(provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)请问此问题怎么解决啊?

解决方案 »

  1.   

    很明显
    1.检查SQL Server的认证方式
    2.检查1433端口是否开放
    3.连接字符串是否有误
      

  2.   

    sql 2008 默认不支持外部连接的。百度一下很多的,用sql外围配置管理器配置一下
      

  3.   

    百度过了   没能解决啊 我本机装了SQL Server2008和VS2008专业版奇怪的是插入操作都没有问题就删除操作不行提示有
    “在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。(provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)
    ”要不我把代码发下吧using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.SqlClient;namespace 超市管理系统
    {
        public partial class 用户管理 : Form
        {
            database link = new database();
            string connectionString;
            public 用户管理()
            {
                InitializeComponent();
                connectionString = Properties.Settings.Default.SuperetConnectionString; 
            }        private void button1_Click(object sender, EventArgs e)
            {
                SqlConnection conn = new SqlConnection(connectionString);
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;
                try
                {
                    conn.Open();
                    if (textBox1.Text == "" || textBox2.Text == "")
                    { MessageBox.Show("请输入用户名和密码"); }
                    else
                    {
                        cmd.CommandText = string.Format("insert into [user](Username,pwd) values ('" + textBox1.Text + "' ,'" + textBox2.Text + "')");
                        cmd.ExecuteNonQuery();
                        conn.Close();
                        MessageBox.Show("添加用户成功!");
                        this.Close();
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);            }
            }        private void button2_Click(object sender, EventArgs e)
            {
                SqlConnection conn = new SqlConnection(connectionString);
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;
                try
                {
                    conn.Open();
                    if (textBox1.Text == "" )
                    { MessageBox.Show("请输入用户名"); }
                    else
                    {
                        cmd.CommandText = string.Format("select * from [user] where Username = '" + textBox1.Text + "'");
                        SqlDataReader dr = cmd.ExecuteReader();
                        if (dr.Read())
                        {
                            string sendSQL = "delete from [user] where Username='" + textBox1.Text.ToString().Trim() + " '";
                            link.UpdateDataBase(sendSQL);
                            conn.Close();
                            MessageBox.Show("该用户已删除!");
                        }
                        else
                        {
                            MessageBox.Show("该用户不存在!");
                        }
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);            }
            }
        }
    }
      

  4.   

    sql = string.Fomat("delete  from tlb where username='{0}'",username);
    link.UpdateDataBase(sql) 中是如何操作的。 
    上面的代码没问题。
      

  5.   


    认证方式没问题连接字符串也没有问题可以执行插入操作就删除操作不行提示“在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。(provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)