-1

大家好,当我在这个函数中添加断点时,我的这段代码正在工作。但是当我在没有断点的情况下运行它时它不起作用请告诉我为什么会发生。当我在带有断点的本地主机上运行这段代码时,这段代码是在线的,然后它工作正常但没有断点显示我不想要的结果

private void GetArticles()
{
    int RowCount = 0;
    sSQL = "SELECT Count(*) FROM tblArticle WHERE Status='Active'";
    using (SqlConnection connection = new SqlConnection(dbConnectionString))
    {
        connection.Open();
        using (SqlCommand command = new SqlCommand(sSQL, connection))
        {
            RowCount = Convert.ToInt32(command.ExecuteScalar().ToString());
        }
    }

    sSQL = "SELECT TOP 3 Aid, Title, ArticleImage, LEFT(Description, 240) FROM tblArticle WHERE Status='Active' ORDER BY newid()";
    using (SqlConnection connection = new SqlConnection(dbConnectionString))
    {
        connection.Open();
        using (SqlCommand command = new SqlCommand(sSQL, connection))
        {
            SqlDataReader reader = command.ExecuteReader();
            int cnt = 0;
            string divname = "book_hotel";
            while (reader.Read())
            {
                string Url = "ViewArticle.aspx?aid=" + reader[0].ToString() + "&Article=" + reader[1].ToString();
                string FinalUrl = GetContextualURL(Url, reader[1].ToString());
                if (FinalUrl.Contains("'"))
                {
                    FinalUrl = FinalUrl.Replace("'", "^");
                }

                if (cnt == 0)
                    divname = "book_hotel";
                else if (cnt == 1)
                {
                    divname = "book_car"; 
                }
                else if (cnt == 2)
                {
                    divname = "book_cruise";
                }

                String p = "<div id='" + divname + "'>" +
                            "<h3>" + reader[1].ToString() + "</h3>" +
                            "<img src=" + reader[2].ToString() + " alt='article' height='140px' width='320px' />" +
                            "<p align='justify' style='width: 320px'>" + reader[3].ToString() + "....." +
                            "</p>" +
                            "<div align='right' style='width: 320px'>" +
                            "<a href='" + FinalUrl + "' class='more'>more</a>" +
                            "</div>" +
                            "</div>";

                ArticleLinks.InnerHtml += p;
                cnt++;
                if (cnt == 4)
                {
                    ArticleLinks.InnerHtml += "</tr><tr>";
                }
            }
        }
    }
}
4

1 回答 1

0

我理解你的问题,那是你的代码只在放置断点?如果删除断点,那么它就不起作用。

如果是,请检查您的调试模式,在本地设置调试模式并在部署服务器时设置发布模式。

但是'这是不可能的,我认为这是一个愚蠢的问题,删除你的 obj 文件夹并运行。或关闭您的视觉工作室,重新打开您的应用程序,然后检查。

于 2013-10-10T11:02:26.750 回答