I have this simple code but it shows error. I dont know where I am going wrong. It shows error in last line.
linq_testDataContext db = new linq_testDataContext();
var remove = from aremove in db.logins
where aremove.username == userNameString && aremove.Password == pwdString
select aremove;
db.logins.DeleteOnSubmit(remove);
DeleteOnSubmit
takes a single object. You are passing an IEnumerable<login>
to it. Use DeleteAllOnSubmit
instead, or select a single object from your resulting collection, like this:
var remove = (from aremove in db.logins
where aremove.username == userNameString
&& aremove.Password == pwdString
select aremove).FirstOrDefault();
if(remove != null)
{
db.logins.DeleteOnSubmit(remove);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With