我想在文本框中的值後搜索數據表的列。我想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的值是相同的搜索字符串,它也會出現在搜索結果中。