I want to search a column of a datatable after values from a textbox. I want to search after ISBN-Numbers
This is my Table "Book":
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));
Now, how can I only search the isbn, without I get values from the whole table? In a Listbox I want to have the Output. There I want to have all Values from the book where the ISBN Number contains the text from the textbox.
My Code I have now to search after the isbn is the following:
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"));
}
But this searches all of the Dataset and when i have a value in an other field withch is the same as the search string, it appears in the search results too.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)