大家好,当我在这个函数中添加断点时,我的代码工作正常。但是,当我没有断点运行它然后它不工作请告诉我为什么它发生。我的这个代码是在线当我在localhost上使用断点运行此代码然后它工作正常但没有断点显示我不希望结果< / p>
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>";
}
}
}
}
}
答案 0 :(得分:0)
我理解你的问题,那就是你的代码只是在设置断点?如果删除了断点那么它就不起作用了。
如果是,请检查调试模式,在本地设置调试模式,并在部署服务器时设置释放模式。
但是'这是不可能的,我认为这是任何愚蠢的问题,删除你的obj文件夹并运行。或关闭您的视觉工作室,重新打开您的应用程序,然后检查。