皆さんこんにちは、この関数にブレークポイントを追加すると、このコードが機能します。しかし、ブレークポイントなしで実行すると機能しませんなぜそれが起こっているのか教えてください
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>";
}
}
}
}
}