Blog

Como llenar un combo c# Windows Mobile 6 sdf db

String full_path = System.Reflection.Assembly.GetCallingAssembly().GetName().CodeBase;
String directory_path = full_path.Substring(0, full_path.LastIndexOf(“\”));

String sdfConnectionString = “Data Source=” + directory_path + “\colectoras.sdf;

SqlCeConnection conn = new SqlCeConnection( sdfConnectionString );
conn.Open();
SqlCeCommand cmd = new SqlCeCommand(“SELECT * FROM Usuario WHERE Habilitado = 1”, conn);
SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);

DataTable dtUsu = new DataTable();
da.Fill(dtUsu);
cboUsuario.ValueMember = “Id”;
cboUsuario.DisplayMember = “Nombre”;
cboUsuario.DataSource = dtUsu;
cboUsuario.SelectedIndex = -1;
conn.Close();