quinta-feira, 1 de setembro de 2011

WPF - Combobox

public void GetDropTpBase() {
SqlConnection sqlCon = new SqlConnection("Data Source=localhost;Initial Catalog=WSsia;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
cmd.Connection = sqlCon;
cmd.CommandType =CommandType.Text;
cmd.CommandText = "select id_tpbase, desc_tpbase from tb_tpbase";
SqlDataAdapter sqlDa = new SqlDataAdapter();
sqlDa.SelectCommand = cmd;

DataSet ds = new DataSet();  

try {sqlDa.Fill(ds, "tb_tpbase");
 comboBoxTPBase.DataContext = ds.Tables["tb_tpbase"].DefaultView;

comboBoxTPBase.DisplayMemberPath = ds.Tables["tb_tpbase"].Columns["desc_tpbase"].ToString();comboBoxTPBase.SelectedValuePath = ds.Tables["tb_tpbase"].Columns["id_tpbase"].ToString();

}


catch (Exception ex) {
   

MessageBox.Show("Ocorreu um erro ao executar o tipo de base!");           
}



finally {

sqlDa.Dispose();

cmd.Dispose();
sqlCon.Dispose();

}

}

        


Att,
Leonardo Rocha.  







           


               

Nenhum comentário:

Postar um comentário

Informações de contato
Nome:
E-mail:
Telefone: