テキストボックスからの値の後にデータテーブルの列を検索したいとします。今データセットのデータテーブルから値を読み取る
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を検索することができます:私はこれが私の表「ブック」である
ISBN-番号の後に検索したいですか? リストボックスには出力があります。 ISBN番号にテキストボックスのテキストが含まれている本から、すべての値を取得したいと考えています。私は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に値を持っている場合、検索文字列と同じです検索結果にも表示されます。