I have inserted the data into the SqlCe Database with the below code:
using (DBContacts context = new DBContacts(ConnectionString))
{
TblContacts tblCtc = new TblContacts();
tblCtc.FirstName = txtBoxFirstNm.Text;
tblCtc.LastName = txtBoxLastNm.Text;
tblCtc.Mobile1 = txtMobile1.Text;
tblCtc.Email1 = txtEmail1.Text;
context.TblContacts.InsertOnSubmit(tblCtc);
context.SubmitChanges();
MessageBox.Show("Inserted Ok.");
}
Questions:
1) How do I use select from Linq To SQL and display the retrieved data ?
using (DBContacts context = new DBContacts(ConnectionString))
{
IEnumerable ctc = from c in context.TblContacts select c;
// what to get the result and display ??
// txtBlkFirstname.Text = ctc.FirstName ??
// txtBlkLastname.Text = ctc.LastName ??
.....
}
1a) Which to use ? IQueryable or IEnumerable?
1b) What does Select-statement return? How to handle the data-return?
1c) How to get the data out from Iqueryable or IEnumerable and assign values to the TextBlock controls?
------ How to bind the data to the ListBox