using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DataSelectRow
{
public partial class Form1 : Form
{
OleDbConnection thisConnection;
OleDbDataAdapter thisAdapter;
DataSet thisDataSet;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DataTable table = thisDataSet.Tables["Books"];
//string expression;
string expression = "Title = '" + textBox1.Text + "'";
DataRow[] foundRows;
foundRows = table.Select(expression); // Use Select method to find all matching rows
foreach (DataRow row in foundRows)
{
textBox2.Text = row["ISBN"] + "\t" + row["Title"] + "\t" + row["Author"] + "\r\n";
}
}
private void Form1_Load(object sender, EventArgs e)
{
thisConnection =
new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\360\Programs_managedVCSharp\rnrbooks.mdb");
thisConnection.Open();
thisAdapter =
new OleDbDataAdapter("SELECT ISBN, Title, Author FROM Books", thisConnection);
thisDataSet = new DataSet();
thisAdapter.Fill(thisDataSet, "Books");
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
thisConnection.Close();
}
}
}