How to fill combobox with database values using n tier architecture

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

John6272

Guest
hi there, i write the code to fill combobox with database value. my code is working correctly if this code written on presentation layer. But i want to written this code on data layer. i have 3 project in my solution (UI, BAL, DLL). i want this code in DLL and then call in UI with the help of BAL. how to do that. please help me. here is my code.

using (SQLiteConnection conn = new SQLiteConnection(DatabaseConnection.ConnectionString()))
{
string CommandText = "SELECT Name FROM User";
using (SQLiteCommand cmd = new SQLiteCommand(CommandText, conn))
{
conn.Open();
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
namecombobox.Items.Add(dr["Name"].ToString());
}
}
}

Continue reading...
 
Back
Top