I need to execute display a list of values in a combo box of a database of acesss
but when i try to run it , it get this error cannot convert System.Windows. Controls.ComboB ox to System.Window.F orms
there is someone who can help me
the class does not have mistake
and i call with a class
Code:
private void paises_Loaded(object sender, RoutedEventArgs e)
{
claDatos datos = new claDatos();
datos.LLenarCombo(pairses, "SELECT * FROM Tabla_Pais", "PAIS", "CODIGO");
}
there is someone who can help me
the class does not have mistake
and i call with a class
Code:
using System;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
namespace CRACKK
{
public class claDatos
{
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\NET\CRACKK\FrontEndEnroll\CRACKK\Storage\DB\Datos.accdb");
public DataTable Consulta(string strSql)
{
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(strSql, conn);
da.Fill(dt);
return dt;
}
public void LLenarCombo(ComboBox combo, string strSql, string codigo, string descripcion)
{
DataTable tabla = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = new OleDbCommand(strSql, conn);
da.Fill(tabla);
combo.ValueMember = codigo;
combo.DisplayMember = descripcion;
combo.DataSource = tabla;
}
}
}
Comment