Ajay_9 0 Newbie Poster

I want access data randomly and i have write the code when i click the button then data is displayed but i want when i again click the button then the next row data is displayed.

could you please tell i am stuck here past 15 days.please
And when click to a particular button which display the option match with database to a 6 column of a every row if its is correct then backcolor of button is green else red.
thank you in advance.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public DataSet ds;
        public OleDbDataAdapter adp;
        OleDbConnection cn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\C#\\Database1.accdb");
        public Form1()
        {
            InitializeComponent();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            cn.Open();
            OleDbDataReader odr;
            OleDbCommand cmd = new OleDbCommand("select * from QUESTION where[Type]=@en", cn);
            cmd.Parameters.AddWithValue("@en", textBox3.Text);
            odr = cmd.ExecuteReader();
            odr.Read();
            if (odr.HasRows)
            {
                textBox2.Text = odr[0].ToString();
                textBox1.Text = odr[1].ToString();
                button1.Text = odr[2].ToString();
                button2.Text = odr[3].ToString();
                button3.Text = odr[4].ToString();
                button4.Text = odr[5].ToString();

            }
            else
            {
                MessageBox.Show("HEhehehehehe");
            }
            cn.Close();
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.