Ver Mensaje Individual
  #13 (permalink)  
Antiguo 17/06/2009, 10:14
kutulay
 
Fecha de Ingreso: mayo-2009
Mensajes: 118
Antigüedad: 15 años
Puntos: 1
Respuesta: Duda en instruccion MySql

No se rellena el grid con ningun dato.... Este es el codigo que tengo

namespace Buscar_O.F_de_un_taller
{
public partial class Form1 : Form
{

private DataSet bdl;//DataSet de datos
private DataTable tabla;//Tabla que almacena datos
private MySqlDataAdapter adaptador;//Objeto que sirve para comunicar al dataset con el DBMS
private MySqlConnection conn;//Objeto que realiza la conexion con el DBMS
private MySqlCommand cmd;//Objeto para la ejecucion de sentencias SQ


public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
bdl = new DataSet("singularity");
tabla = new DataTable("eventrecord");
conn = new MySqlConnection("Database=singularity;Data Source=localhost;User Id=root;Password=825200");
cmd = new MySqlCommand("Sentencia SQL", conn);
adaptador = new MySqlDataAdapter(cmd);
}

string taller;
private void button1_Click(object sender, EventArgs e)
{
taller = textBox1.Text;
conn.Open();//Abre la conexion
if (bdl.Tables.Count == 0)
{

cmd.CommandText = "SELECT substring(readerid,1,4) FROM eventrecord WHERE readerid LIKE '" + taller +"%'";
adaptador.Fill(tabla);
bdl.Tables.Add(tabla);

}

else
{

bdl.AcceptChanges();
adaptador.Update(bdl, "eventrecord");

}

dataGridView1.DataSource = bdl.Tables["eventrecord"];
dataGridView1.Update();
conn.Close();//Cierra la conexion
this.dataGridView1.AllowUserToAddRows = false;
textBox2.Text = dataGridView1.Rows.Count.ToString();
}

private void button2_Click(object sender, EventArgs e)
{
this.textBox1.Text = "";
this.textBox2.Text = "";
dataGridView1.DataSource = null;
Application.Restart();
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
taller = textBox1.Text;
}

}
}