22 Replies
the bug is i can't remove any data from database
db.tblProduct.Remove(x);
you don't call SaveChanges ? 🤔
nope bro
it's throw exception
in debug
what's the exception ? 🤔
wait a sec
first
we have 1 more exception
Severity Code Description Project File Line Suppression State
Error CS1503 Argument 1: cannot convert from 'int' to 'Logiwa.ProductManagement.tblProduct' Logiwa.ProductManagement
on which line ?
db.tblproduct.remove(x);
LogiwaEntities1 db = new LogiwaEntities1();
ProductData productData = new ProductData();
productData.ProductName = txtProductName.Text;
string productName = productData.ProductName;
var x = db.tblProduct.Where(p => p.PRODUCTNAME == productName)
.Select(p => p.PRODUCTID)
.FirstOrDefault();
label3.Text = Convert.ToString(x); it's working but i can't remove X from database
i can see ID on label
looks like ProducManagement things is not valid
what's type is tblProduct ?
what
cannot convert from 'int' to 'Logiwa.ProductManagement.tblProduct
sometimes my english is not enough
ooh
tblProduct is not supposed to have an int
yeah it's a datatable
GitHub
GitHub - polymorphism69/Logiwa.ProductManagement
Contribute to polymorphism69/Logiwa.ProductManagement development by creating an account on GitHub.
the code has a lot of bug it's not done
this code from ProductManagement.cs
if you want to view the codes
remove take an entity not an id for some reason
and x is an int
you are selecting only the ID
var x = db.tblProduct.Where(p => p.PRODUCTNAME == productName)
.Select(p => p.PRODUCTID)
.FirstOrDefault();
they want do everything with using ID not product name, we don't want to use product name
try to remove the Select and see if it works
i've solved it
i'm almost sure if you do that it works
@UmutAtomic
i used this way to solve it @x0rld
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.