简体   繁体   English

在 IIS 中发布 web 应用程序后出错

[英]Error after publishing a web application in IIS

No matter what I do I get this error during run-time:无论我做什么,我都会在运行时收到此错误:

ExecuteReader requires an open and available Connection. ExecuteReader 需要一个打开且可用的连接。

I have verified that this error is thrown with every SQL service access in my app, I've made sure that every time I access the DB, the connection is opened and then closed respectively.我已经验证在我的应用程序中的每个 SQL 服务访问都会引发此错误,我确保每次访问数据库时,连接都会分别打开然后关闭。

Hare's an example of my DB class Code:野兔是我的 DB class 代码的示例:

    public void ConexionDB()
    {
        try
        {
            cnx = new SqlConnection();
            cnx.ConnectionString = "Data Source=DESKTOP-GAHK8CT;Initial Catalog=WInventario;Integrated Security=True";
            cnx.Open();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }

    public void DELETE_Lineas(int ID)
    {
        try
        {
            ConexionDB();
            SqlCommand cmd = new SqlCommand("spDELETE_Linea", cnx);
            cmd.Connection = cnx;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@ID_Linea", ID));
            cmd.ExecuteNonQuery();
            cnx.Close();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
            cnx.Close();
            throw;
        }
    }

My Application Pool Settings我的应用程序池设置

I have also made sure that the folder that contains has all the permissions with all the available users (Full access).我还确保包含的文件夹具有所有可用用户的所有权限(完全访问权限)。

I'm not sure what else I can check to make it work.我不确定我还能检查什么以使其正常工作。

Change -> Data Source=DESKTOP-GAHK8CT to Data Source=localhost更改 -> 数据源=DESKTOP-GAHK8CT 为数据源=localhost

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM