How to show values in textboxes when combobox value select in c# windows application using layer architecture

  • Thread starter Thread starter John6272
  • Start date Start date
J

John6272

Guest
hi, i have a code to show combobox value in textboxes and code work fine for me but i convert my project into layer architecture (UI, BLL, DAL, Entity). i don't know c# very well and i'm learning the c#. my problem is that i want to change my code into layer architecture but don't know how to do that, please help me. here is the code.

using (SQLiteConnection conn = new SQLiteConnection("Data Source=combolist.db;Version=3;"))
{
string CommandText = "SELECT * FROM combo WHERE [Id]=@id";
using (SQLiteCommand cmd = new SQLiteCommand(CommandText, conn))
{
cmd.Parameters.AddWithValue("@id", comboBox1.SelectedItem.ToString());
conn.Open();
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
textBox1.Text = dr["Id"].ToString();
textBox2.Text = dr["FirstName"].ToString();
textBox3.Text = dr["LastName"].ToString();
textBox4.Text = dr["Age"].ToString();
textBox5.Text = dr["Address"].ToString();

}
}
}

Continue reading...
 
Back
Top