没有断点的 C# 代码将无法工作
本文关键字:工作 代码 断点 | 更新日期: 2023-09-27 18:34:40
大家好,当我在此函数中添加断点时,我的这段代码正在工作。但是当我在没有断点的情况下运行它时,它不起作用,请告诉我为什么当我在带有断点的 localhost 上运行此代码时,它 happening.my 此代码在线,然后它工作正常,但没有断点显示我不是想要的结果
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>";
}
}
}
}
}
我理解你的问题,那就是你的代码只在放置断点——如果删除断点,那么它就不起作用。
如果是,请检查你的调试模式,在本地设置调试模式,部署服务器时设置发布模式。
但是'这是不可能的,我认为这是任何愚蠢的问题,删除你的obj文件夹并运行。 或者关闭你的视觉工作室,重新打开你的应用程序,然后检查。