我想在文本框中的值后搜索数据表的列。我想ISBN号码从数据集的数据表中读取值
后搜索这是我的表“周易”:
DataColumn bookName = new DataColumn("BookName", typeof(string));
DataColumn bookId = new DataColumn("BookId", typeof(int));
DataColumn isbn = new DataColumn("ISBN", typeof(string)); //should be an EAN-13
Barcodeenter code here
DataColumn book_authorId = new DataColumn("Book_AuthorId", typeof(int));
DataColumn bookprice = new DataColumn("Price", typeof(decimal));
DataColumn authorName = new DataColumn("AuthorName", typeof(string));
DataColumn authorId = new DataColumn("AuthorId", typeof(int));
DataColumn geschlecht = new DataColumn("Geschlecht", typeof(string));
现在,我怎么能只搜索书号,没有我从整个表中获取价值? 在列表框中我想要输出。在那里,我想拥有ISBN号包含文本框中文本的书中的所有值。
我的代码我现在有书号后,搜索如下:
string isbn = _tbIsbnSuche.Text;
string result = String.Empty;
string file = _tempPath + @"\book_authorData.xml";
XmlTextReader r = new XmlTextReader(file);
if (isbn != String.Empty)
{
_lbInformation.Text = String.Empty;
_lBdatenOutput.BackColor = Color.LightGoldenrodYellow;
_lBdatenOutput.Items.Clear();
_lBdatenOutput.Items.Insert(0, "Please Wait!");
_lBdatenOutput.Items.Insert(1, "Gefundene ISBN-Nummern:");
while (r.Read())
{
if (r.Value.Trim().IndexOf(isbn) != -1 && r.Value.Trim().Contains("-") && r.Value.Length >= 13)
{
_lBdatenOutput.Items.Add(r.Value.Trim());
}
}
tim.Enabled = true;
}
else
{
_lbInformation.ForeColor = Color.Red;
_lbInformation.Text = _suchfehler;
}
//Wenn keine Datensätze gefunden wurden
if (_lBdatenOutput.Items.Count == 2)
{
tim.Enabled = true;
_lBdatenOutput.BackColor = Color.OldLace;
_lBdatenOutput.Items.Add(String.Concat("Es wurden keine Bücher welche in der ISBN-Nummer die Zeichenfolge ", "\"", isbn, "\"", " enthalten gefunden"));
}
但这搜索所有数据集的,当我在另一场withch的值是相同的搜索字符串,它也会出现在搜索结果中。