![](/img/trans.png)
[英]How to decrypt an encrypted key from database and use it for fetching data from database in C# asp.net . Encryption is done with AES
[英]skipping rows from table while fetching data from database asp. net C#
fees_structure
有24個“ A”類別行。 但是當我嘗試獲取它們並打印時,它僅顯示20或(有時為21行)
這是我的代碼:
string catA = "SELECT id,fees_name,amount,fee_category FROM fees_structure where fee_category='A' ORDER BY id";
using (SqlCommand scom = new SqlCommand(catA, con))
{
using (SqlDataReader read = scom.ExecuteReader())
{
read.Read();
if (read.HasRows)
{
while (read.Read())
{
feestableA.Append("<tr>");
feestableA.Append("<td>" + read["fees_name"] + "</td>");
feestableA.Append("<td>" + read["amount"] + "</td>");
feestableA.Append("</tr>");
}
plcfeesA.Controls.Add(new Literal { Text = feestableA.ToString() });
plcfeesA.Dispose();
}
}
}
while
之前的read()
可疑。 我懷疑那是一排。
丟失行的另一種可能性是區分大小寫的排序規則-如果類別可以是'a'
(或另一種編碼的變體)。 但是,這取決於用於列,數據庫和服務器的默認或顯式排序規則。
我不認為這是C#問題。
嘗試這個
string catA = "SELECT id,fees_name,amount,fee_category FROM fees_structure where fee_category like '%A%' ORDER BY id";
只要看看你的結果是否改變
嘗試這個。 仔細觀察,我刪除了執行您不想做的事情的代碼行。
string catA = "SELECT id,fees_name,amount,fee_category FROM fees_structure where fee_category='A' ORDER BY id";
using (SqlCommand scom = new SqlCommand(catA, con))
{
using (SqlDataReader read = scom.ExecuteReader())
{
while (read.Read())
{
feestableA.Append("<tr>");
feestableA.Append("<td>" + read["fees_name"] + "</td>");
feestableA.Append("<td>" + read["amount"] + "</td>");
feestableA.Append("</tr>");
}
plcfeesA.Controls.Add(new Literal { Text = feestableA.ToString() });
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.