I have a mysql database linked to a tab control with multiple tables. I got the first table display in one tab page. But I cannot get the data to be displayed into another tab control. How do I do this? Also What is the code to perform the insert, update and delete the data?
- using System.Xml.Linq;
- using MySql;
- using System.Configuration;
- using MySql.Data;
- using System.Xml;
- using System.IO;
- using System.Runtime.InteropServices;
- using Telerik.WinControls;
- using Telerik.WinControls.UI;
- using Telerik.WinControls.UI.Docking;
- using System.Globalization;
-
- namespace mydatabase
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
-
- private void Form1_Load(object sender, EventArgs e)
- {
- this.IsMdiContainer = true;
- string constring = "datasource=localhost;Port=3306;database=mydatabase;username=root;password=mypassword;persist security info=True";
- MySqlConnection MySqlConn = new MySqlConnection(constring);
- MySqlCommand command = new MySqlCommand("select * from mydatabase.Authors;", MySqlConn);
-
- try
- {
-
- MySqlDataAdapter daAuthors = new MySqlDataAdapter();
- daAuthors.SelectCommand = command;
- DataTable dtAuthors = new DataTable();
- DataSet dsAuthors = new DataSet();
- daAuthors.Fill(dtAuthors);
- dsAuthors.Tables.Add(dtAuthors);
-
- dtAuthors.Columns["AuthorID"].AutoIncrement = true;
- dtAuthors.Columns[0].AutoIncrementStep = 1;
-
-
-
- BindingSource AuthorBindingSource = new BindingSource();
-
- AuthorBindingSource.DataSource = dtAuthors;
- AuthorBindingNavigator.BindingSource = AuthorBindingSource;
-
- txtAuthorID.DataBindings.Add("Text", AuthorBindingSource, "AuthorID");
- txtAuthorCode.DataBindings.Add("Text", AuthorBindingSource, "AuthorCode");
- txtAuthorName.DataBindings.Add("Text", AuthorBindingSource, "AuthorName");
-
-
-
-
-
-
-
-
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
-
-
- string conBook = "datasource=localhost;Port=3306;database=mydatabase;userid=root;password=mypassword;persist security info=True";
- MySqlConnection mySqlConnBook = new MySqlConnection(conBook);
- MySqlCommand cmdBook = new MySqlCommand("SELECT * From mydatabase.Book", mySqlConnBook);
-
- MySqlDataAdapter daBook = new MySqlDataAdapter();
- daBook.SelectCommand = cmdBook;
- DataTable dtBook = new DataTable();
- DataSet dsBook = new DataSet();
-
- daBook.Fill(dtBook);
- dsBook.Tables.Add(dtBook);
-
-
- dtBook.Columns["BookCodeID"].AutoIncrement = true;
- dtBook.Columns[0].AutoIncrementStep = 1;
-
-
-
- BindingSource BookBindingSource = new BindingSource();
-
- BookBindingSource.DataSource = dtBook;
- BookBindingNavigator.BindingSource = BookBindingSource;
-
- txtBookCodeID.DataBindings.Add("Text", BookBindingSource, "BookCodeID");
- txtBookDescription.DataBindings.Add("Text", BookBindingSource, "BookDescription");
- }
- }
-
- private void next_radPageViewPage(RadPageViewPage radPageViewPage1, RadPageViewPage radPageViewPage2)
- {
- radPageView1.SelectedPage = radPageViewPage2;
- radPageViewPage2.BindingContextChanged += (_, __) =>
- radPageView1.SelectedPage = radPageViewPage1;
- }
-
- }
- }