运行简单Web应用程序时出错" System.ComponentModel.Win32Exception:找不到网络路径"

时间:2015-08-26 18:41:01

标签: asp.net

我试图运行此代码,但它在con.Open()方法中引发错误 " System.ComponentModel.Win32Exception:找不到网络路径"

public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string cs = "server = (localdb)\v11.0 ;  database =     DepartmentsAndEmployees ; integrated security=true";
            SqlConnection conn = new SqlConnection(cs);
            SqlCommand com = new SqlCommand("select * from Employees", conn);
            conn.Open();            
            GridView1.DataSource = com.ExecuteReader();
            GridView1.DataBind();            
            conn.Close();
        }
    }

1 个答案:

答案 0 :(得分:0)