1
Answer

how to load database in a listview with linq to sql?

Abolfazl

Abolfazl

10y
1.3k
1
hi
i want to load a table of database to a listview.i know how to create columns for listview and how to add items in them,
but i don't know how to add data from database with linq.
i write this code:
 
databaseDataContext db = new databaseDataContext();
var query = db.accountinfos;
for (int i = 0; i < query.Count();i++ )
{
var field = db.accountinfos.Where(c => c.id == i+1).Single();
ListViewItem item = new ListViewItem(field.bankname.ToString());
item.SubItems.Add(field.accountnumber.ToString());
}
 
please help me. 
thanks 
 
 
 
Answers (1)