How to delete record in SqlCe Db for windows phone
-
lunes, 06 de agosto de 2012 8:11
Have two tables ; Master and child as below:
tblMaster
==========
MId
DateOfTransact
Note
tblChild
======
Cid
Mid
TypeOfTransaction
Time
AmountQuestions:
1. How to delete all the Records in Tables Master and child?
Todas las respuestas
-
lunes, 06 de agosto de 2012 10:19Moderador
Get all records from tblChild, delete them, submitchanges, get all records fro tblMaster, delete them, submit changes. See some sample code here: http://erikej.blogspot.dk/2012/04/windows-phone-local-database-tip.html
Please mark as answer, if this was it. Visit my SQL Server Compact blog
-
lunes, 06 de agosto de 2012 11:31
Thanks for the link. Here the two methods.
Can use method 1 into Method 2 where :
context3.tblChild.DeleteOnSubmit(Rcd) instead using foreach- statement?
===================Method 1:
-----------
var list = db.InvoiceLine.Take(100);
db.InvoiceLine.DeleteAllOnSubmit(list);Method 2
-------------
using (DbTransact context3 = new DbTransact(ConnectionString))
{
var Rcd = from c in tblChild
where c.Mid == Convert.ToInt32(strIdNo)
select c;foreach (var c in Rcd )
{
context3.tblChild.DeleteOnSubmit(c);
}context3.SubmitChanges();
}
- Propuesto como respuesta amber zhangModerator martes, 07 de agosto de 2012 1:35
- Marcado como respuesta amber zhangModerator lunes, 13 de agosto de 2012 1:31

