[英]getting multiple data from msacess ASP.NET C#
when ever i run this code i get only one output i would like to get all results starting with letter D
每当我运行此代码时,我只会得到一个输出,我想获得所有以字母D
开头的结果
using (OleDbConnection conn = new OleDbConnection(connString))
{
OleDbCommand cmd = new OleDbCommand("SELECT * FROM users WHERE title LIKE 'D%' ",conn);
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(results);
if (results.Rows.Count !=0)
{
using (OleDbDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
title = reader[1].ToString();
searchbox.InnerText = title;
}
}
}
else
{
searchbox.InnerText = "NOTHING FOUND";
}
defualt.aspx defualt.aspx
<li id="searchbox"></li>
your reader is going through the results and changing the title with each row. 您的读者正在浏览结果并更改每一行的标题。 you need to "add" the value of each row to the result: title += reader[1].ToString();
您需要将每一行的值“添加”到结果中: title += reader[1].ToString();
this won't look correct at first, you'll have to adjust it, but it should get all the results out. 乍一看看起来不正确,您必须对其进行调整,但它应该可以得出所有结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.