Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在语句sqlCon.open“处获取错误;System.Data.SqlClient.SqlException';发生在System.Data.dll中,但未在用户代码中处理;_C#_Html_Asp.net_Sql Server - Fatal编程技术网

C# 在语句sqlCon.open“处获取错误;System.Data.SqlClient.SqlException';发生在System.Data.dll中,但未在用户代码中处理;

C# 在语句sqlCon.open“处获取错误;System.Data.SqlClient.SqlException';发生在System.Data.dll中,但未在用户代码中处理;,c#,html,asp.net,sql-server,C#,Html,Asp.net,Sql Server,请确保如果Sql server作为默认实例运行,则需要在数据源中使用“.”,例如 public partial class Webpages_Default : System.Web.UI.Page { SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString); protected void Page_Load(objec

请确保如果Sql server作为默认实例运行,则需要在数据源中使用“.”,例如

public partial class Webpages_Default : System.Web.UI.Page
{
    SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString);

    protected void Page_Load(object sender, EventArgs e)
    {
        lblnorecordfound.Visible = false;
        gvRCATracker.Visible = false;

        if (!IsPostBack) {
            //Binding control
            sqlCon.Open();
            BindPriority();
            BindProductCategory();
            BindPortfolio();
            BindRCAResponseTeam();
            BindTSMReview();
            BindRCAStatus();

            sqlCon.Close();

            SetReadOnlyForDateControls();
        }               
    }
}
否则,您需要指定服务器实例的名称

connectionString="Data Source=.;Initial Catalog=LMS;User ID=sa;Password=password"
您需要捕获异常并查看它提供的所有信息(同时查看可能的
。InnerException
!!)
connectionString="Data Source=.\INSTANCENAME;Initial Catalog=LMS;User ID=sa;Password=password"