Ich habe eine Methode erstellt, mit der ich eine Access-Datenbank mit oledbdatareader durchsuchen kann, aber ich kann nicht herausfinden, wie ich mit einer Schaltfläche zum nächsten Datensatz wechseln kann.Zum nächsten Datensatz mit oledbdatareader wechseln C#
Bitte helfen!
private void button2_Click(object sender, EventArgs e)
{
System.Data.OleDb.OleDbConnection conn = new
System.Data.OleDb.OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BoilerSvc_be.mdb";
try
{
conn.Open();
OleDbCommand command = new OleDbCommand("SELECT Equipment.CustID AS CustID,Equipment.Manufacturer AS Manufacturer,Equipment.Model AS Model, Equipment.LastService AS LastService,Initial,Surname,[Address 1],[Address 2],[Address 3],[Post Town],[Post Code],Telephone FROM Contacts INNER JOIN Equipment ON Equipment.CustID = Contacts.CustID WHERE Surname = '" + textBox12.Text + "' OR Initial = '" + textBox12.Text + "' OR[Post Town] = '" + textBox12.Text + "' OR[Post Code] = '" + textBox12 + "'", conn);
command.Parameters.Add(new OleDbParameter("@Name", textBox12));
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
FirstName.Text = reader["Initial"].ToString();
LastName.Text = reader["Surname"].ToString();
Address1.Text = reader["Address 1"].ToString();
Address2.Text = reader["Address 2"].ToString();
Address3.Text = reader["Address 3"].ToString();
TownCity.Text = reader["Post Town"].ToString();
PostCode.Text = reader["Post Code"].ToString();
Telephone.Text = reader["Telephone"].ToString();
LstSvcDat.Text = reader["LastService"].ToString();
BoilerMan.Text = reader["Manufacturer"].ToString();
BoilerMod.Text = reader["Model"].ToString();
}
// Insert code to process data.
}
finally
{
conn.Close();
}