private void button4_Click(object sender, EventArgs e) { frm_reporte_cotizacion cot = new frm_reporte_cotizacion(); string id = lbl_id.Text; object celda = dataGridView1.CurrentCell.Value; string data = ""; string campo = ""; string campo2 = ""; switch (id) { case "1": data = mtb_cedula_c.Text; campo = "a.cedula"; campo2 = "cedula_c"; break; case "2": data = maskedTextBox1.Text; campo = "a.cedula"; campo2 = "cedula_c"; break; case "3": data = textBox4.Text; campo = "a.nombre"; campo2 = "nombre_c"; break; case "4": data = textBox2.Text; campo = "a.apellido"; campo2 = "apellido_c"; break; } //string datos = cbx_estado.SelectedItem.ToString(); con.Open(); MySqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT b.nombre as Gasto, b.monto as Monto, b.detalle as Detalle, a.nombre as Nombre, a.apellido as Apellido, a.cedula as Cedula, a.oficialia_civil as Oficialia FROM pr_clientes AS a INNER JOIN pr_gastos AS b ON a.client_Id = b.client_Id where a.hidden=0 and " + campo + "='" + data + "' and b.tipo = '" + celda + "'"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); MySqlDataAdapter da = new MySqlDataAdapter(cmd); this.dataGridView2.Visible = true; da.Fill(dt); cot.dataGridView1.DataSource = dt; cot.Show(); con.Close(); }