hi guys,

i have start working with C#, i m making a simple application for my office, i m using mysql database. my question is i want to make a record navigation button like: Next, Previous ..... kindly guide me how to make this. i m using mysql database with mysqlconnector. i hope someone reply me correctly.

i have repeate my post with code this time.
*******************************************

private void btnNext_Click(object sender, EventArgs e)
        {
            string myConnection = "datasource=localhost;port=3306;username=root";
            MySqlConnection myconn = new MySqlConnection(myConnection);
            MySqlCommand com = new MySqlCommand("select count(id) from dbcj.kartype", myconn);

            MySqlDataAdapter dataAdapter = new MySqlDataAdapter("SELECT type FROM dbcj.kartype", myconn);
            DataSet dataSet = new DataSet();
            dataAdapter.Fill(dataSet);

            myconn.Open();
            object count = com.ExecuteScalar();
            int counter = Convert.ToInt32(count);
            if (count != null)
            {
                int i = 1;
                while (i > counter)
                {
                    typeBox.Text = dataSet.Tables[0].Rows[i]["type"].ToString();
                    i++;
                }

               /*
                foreach (string ii in counter.ToString())
                {
                    typeBox.Text = dataSet.Tables[0].Rows[i]["type"].ToString();
                }*/
            }

Hello kamran815! :)
It looks like you're using ADO.NET to connect to your data stored (i.e. mysql). Is that an absolute must or are you open to using LINQ? The LINQ methods have simplified access to data from RDBMS. Take a look at this tutorial if you're not familiar with it: https://msdn.microsoft.com/en-us/data/ff728653.aspx

Let me know if you have any questions:

Tekkno

Hello again kamran815...
Looking over your code, it looks like you're planning to scroll through each record one by one. I'm not certain what your requirements and specs are for this application, but if you just need to pull up records, and say, access them for editing, you might try using the GridView control, and a Master/Detail pattern. You can learn more about this at: https://msdn.microsoft.com/en-us/library/aa581795.aspx

Tekkno

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.