ASP.net站点适用于开发机器,但不适用于IIS-DB连接

时间:2016-05-12 13:17:39

标签: c# sql asp.net iis

我有一个ASP.net站点,在开发环境中工作正常,但在部署到IIS时不会产生输出。该网站有一个带标签的计时器和更新面板。在计时器的每个刻度上,代码从与IIS服务器在同一台计算机上托管的SQL DB中提取值。

这是代码

protected void Page_Load(object sender, EventArgs e)
    {
        UpdateTimer.Enabled = true;
    }

    protected void UpdateTimer_Tick(object sender, EventArgs e)
    {
        string constring = "Data Source = LEWBWPDEV\\COMPLIANCE; Initial Catalog = 3CXCallStats; Integrated Security = True; Max Pool Size = 500";
        string select = "SELECT * FROM callsCounter WHERE ID = '1'";
        string count = "";
        SqlConnection myCon = new SqlConnection(constring);
        SqlCommand selectCMD = new SqlCommand(select, myCon);
        SqlDataReader myReader;

        myCon.Open();
        myReader = selectCMD.ExecuteReader();
        while (myReader.Read())
        {
            count = myReader["Counter"].ToString();
        }

        lblCounter.Text = count;
    }

我需要更改我的数据源吗?我尝试过(本地),localhost和127.0.0.1。

非常感谢任何和所有帮助。

0 个答案:

没有答案