【发布时间】:2023-03-26 20:40:01
【问题描述】:
大家好,当我在这个函数中添加断点时,我的这段代码正在工作。但是当我在没有断点的情况下运行它时它不工作请告诉我为什么会这样/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>";
}
}
}
}
}
【问题讨论】:
-
什么是“不工作”,你得到什么结果?你期待什么结果?
-
你的意思是当你将它部署到服务器时不起作用?
-
我觉得你的问题很有趣。这怎么可能?
-
您是否遇到任何异常或错误?
-
你把断点放在哪里?你说的不完全工作是什么意思?
标签: c# asp.net breakpoints