bindingNavigator1 es una barra con botones de navegacion que se ubica en la parte superior del formulario, como muestra la fig. de abajo.
C#
using MySql.Data.MySqlClient; // Agregar libreria MySql
namespace pryGrabar{
public partial class Form9 : Form
{
MySqlConnection conn = new MySqlConnection();
public Form9()
{
InitializeComponent();
carga();
}
private void carga()
{
string SQL = "select * from tutorials;";
string cad; string[] A = new string[3];
cad = "server=127.0.0.1;uid=minuvasoft;pwd=4321;database=ventas";
try
{
conn.ConnectionString = cad;
conn.Open();
MySqlDataAdapter adp = new MySqlDataAdapter(SQL,conn);
DataSet ds = new DataSet();adp.Fill(ds,"tutorials");
adp.Dispose();
bindingSource1.DataSource = ds;
bindingSource1.DataMember = "tutorials";
textBox1.DataBindings.Add("Text",bindingSource1,"tutorial_id");
textBox2.DataBindings.Add("Text", bindingSource1, "tutorial_title");
textBox3.DataBindings.Add("Text", bindingSource1, "tutorial_author");
textBox4.DataBindings.Add("Text",bindingSource1,"precio");
conn.Close();
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
En propiedades de bindingNavigator1 agregar bindingSource1.
minuvasoft@hotmail.com Miguel Nunez.
No hay comentarios:
Publicar un comentario