
18/02/2010, 15:13
|
| | Fecha de Ingreso: diciembre-2009 Ubicación: Chile
Mensajes: 9
Antigüedad: 15 años, 2 meses Puntos: 0 | |
Respuesta: visual c# cargar combobox con bd sqlserver 2000 Ya que nadie me dio una mano yo se las doy a los chicos que no pudieron hacerlo, ya lo solucione.
private void cbb_Comercio_SelectedIndexChanged(object sender, EventArgs e)
{
if (flag1 == 0)
{ }
else
{
open_DB();
string query = @"select CodLocal, Sucursal from sip.dbo.local Where codcadena = " + cbb_Cadena.SelectedValue + "and codcomercio = " + cbb_Comercio.SelectedValue;
SqlCommand cmd2 = new SqlCommand(query, conn);
cmd2.Parameters.AddWithValue("cod", cbb_Comercio.SelectedValue);
SqlDataAdapter DaRec2 = new SqlDataAdapter(cmd2);
DataTable DtLocal = new DataTable();
DaRec2.Fill(DtLocal);
foreach (DataRow row in DtLocal.Rows)
{
row["Sucursal"] = string.Format("({0}) - {1}", row["CodLocal"], row["Sucursal"]);
}
DataRow newRow = DtLocal.NewRow();
newRow["CodLocal"] = 0;
newRow["Sucursal"] = "Todos";
DtLocal.Rows.InsertAt(newRow, 0);
cbb_Local.DataSource = DtLocal;
cbb_Local.DisplayMember = "Sucursal";
cbb_Local.ValueMember = "CodLocal";
flag1 = 1;
cbb_Local.Enabled = true;
flag2 = 1;
conn.Close();
}
} |