using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class DatabaseWeb : System.Web.UI.Page
{
OleDbConnection thisConnection;
OleDbDataAdapter thisAdapter;
DataSet thisDataSet;
protected void Page_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");
}
protected void Button1_Click(object sender, EventArgs e)
{
DataTable table = thisDataSet.Tables["Books"];
string expression = "Title = '" + TextBox1.Text + "'";
DataRow[] foundRows;
foundRows = table.Select(expression); // Use Select method to find all matching rows
if (foundRows.Length > 0)
{
foreach (DataRow row in foundRows)
{
TextBox3.Text = row["Author"].ToString();
TextBox2.Text = row["ISBN"].ToString();
}
}
else
TextBox2.Text = TextBox3.Text = "Not found";
}
}