Question Record Navigation Button

kamran815

New member
Joined
Feb 28, 2015
Messages
3
Programming Experience
Beginner
i m very new in learning C# programming, i m using visual studio 2010 express, i have made an application connected with MYSQL, i want to create record Navigation Button like (Next, Previous, Last, First), but i have no idea what code should put in this. i hope anyone can help to sort out this issue.

waiting for useful response
 
You can add a BindingNavigator to form and assign it your BindingSource. If you want to use your own buttons you can use BindingSource methods MoveNext etc.
 
thanks a lot johnH for reply my question, actually i m using MySql database thats why i asked this question. i connect Mysql database with mysql .net connector. i would appreciate if you give some nice advise in this context.
 
BindingSource is a class in .Net framework, MySql Connector library doesn't have a special version of this class. It is commonly used between data source (typically a DataTable or DataSet) and bound UI control, and you should use it too.
 
Record Navigation Button in C#

BindingSource is a class in .Net framework, MySql Connector library doesn't have a special version of this class. It is commonly used between data source (typically a DataTable or DataSet) and bound UI control, and you should use it too.

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["type"].ToString();
i++;
}



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


/*MySqlDataReader reading;
reading = com.ExecuteReader();
reading.Read();
//typeBox.Text = reading[Convert.ToInt32(count)].ToString();
//TextBox1.Text = ds.Tables[0].Rows[0]["au_id"].ToString();
*/













//myconn.Close();
}

dear, i have tried all these codes but did not get any result :( can u help me?
 
Unless you need multiple datatables in one set skip the dataset and just use a datatable, Fill that instead of dataset. Add a BindingSource to your form. In code you can either set its DataMember (name of datatable) and DataSource (dataset), or if you're just using datatable set that as DataSource. Bind the textbox by adding a Binding in its DataBindings. Use BindingNavigator as explained before. Here's some reading material: Windows Forms Data Binding
 
Back
Top Bottom