C
C#zita epsilon

❔ This code is bugged how can i solve it?

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);
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);
db.tblProduct.Remove(x);
ZE
zita epsilonβ€’401d ago
the bug is i can't remove any data from database db.tblProduct.Remove(x);
X
x0rldβ€’401d ago
you don't call SaveChanges ? πŸ€”
ZE
zita epsilonβ€’401d ago
nope bro it's throw exception in debug
X
x0rldβ€’401d ago
what's the exception ? πŸ€”
ZE
zita epsilonβ€’401d ago
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
X
x0rldβ€’401d ago
on which line ?
ZE
zita epsilonβ€’401d ago
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
X
x0rldβ€’401d ago
looks like ProducManagement things is not valid what's type is tblProduct ?
ZE
zita epsilonβ€’401d ago
what
X
x0rldβ€’401d ago
cannot convert from 'int' to 'Logiwa.ProductManagement.tblProduct
ZE
zita epsilonβ€’401d ago
sometimes my english is not enough ooh
X
x0rldβ€’401d ago
tblProduct is not supposed to have an int
ZE
zita epsilonβ€’401d ago
yeah it's a datatable
ZE
zita epsilonβ€’401d ago
GitHub
GitHub - polymorphism69/Logiwa.ProductManagement
Contribute to polymorphism69/Logiwa.ProductManagement development by creating an account on GitHub.
ZE
zita epsilonβ€’401d ago
the code has a lot of bug it's not done this code from ProductManagement.cs if you want to view the codes
X
x0rldβ€’401d ago
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();
ZE
zita epsilonβ€’401d ago
they want do everything with using ID not product name, we don't want to use product name
X
x0rldβ€’401d ago
try to remove the Select and see if it works
ZE
zita epsilonβ€’400d ago
i've solved it
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);
var y = db.tblProduct.Find(x);
db.tblProduct.Remove(y);
db.SaveChanges();
label3.Show();
MessageBox.Show("Product removed!", "Info",MessageBoxButtons.OK,MessageBoxIcon.Information);
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);
var y = db.tblProduct.Find(x);
db.tblProduct.Remove(y);
db.SaveChanges();
label3.Show();
MessageBox.Show("Product removed!", "Info",MessageBoxButtons.OK,MessageBoxIcon.Information);
X
x0rldβ€’400d ago
i'm almost sure if you do that it works
var x = db.tblProduct.Where(p => p.PRODUCTNAME == productName).FirstOrDefault();
db.tblProduct(x);
var x = db.tblProduct.Where(p => p.PRODUCTNAME == productName).FirstOrDefault();
db.tblProduct(x);
@UmutAtomic
ZE
zita epsilonβ€’400d ago
i used this way to solve it @x0rld
A
Accordβ€’399d ago
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.
Want results from more Discord servers?
Add your server
More Posts
βœ… How to add hover effect to WPF button elementThis code I'm using isn't working. When I hover over buttons its a lightblue color. <Style with or without refso i learned that in c#(or most oop languages) when you create a method that takes an object as a paβœ… .net trying to find non-existent cs files`Error IDE1100 Error reading content of source file 'D:\Dev\C++\Test\TestCS\obj\Debug\net6.0\.❔ WPF - Binding to last child of collectionI have the following setup: ```csharp public partial class StatusMessageService : ObservableObject βœ… What does WPF want from me?I'm actually so tired of WPF and MVVM and all this contrived fuckin bs you guys MainWindow control:❔ I apparently have an infinite loop, but I can't fix it to workI've tried a lot of stuff, even a "NewtonJson" fix I saw, but it wouldn't solve the problem because βœ… doing nothingdfg❔ I would appreciate some help.So i have this assignment and in lieu of my grandma who passed this past week i've not had the oppor❔ Discord Bot Service ProblemDoes anyone know how to register that service properly?❔ abstract class vs interface```cs public interface IFoo { protected static string GetFormattedTime() => DateTimeβœ… Refit / RestLess API SDK StructureHey! How do I structure an SDK for my API? Let's say I have 2 resources: Users and Groups. I coul❔ Best way to display a continually updating list of messages```cs @inject MerpieClient Client @inject MerpieHubConnection HubConnection @inject ILogger<MessageL❔ How can I fix this I keep getting null value in my string variable❔ How do I go from interface to implementation while navigating ASP.NET core code?I saw this youtube video and he seamlessly navigates the source? How can I do this? Thanks.Console Application published as PublishSingleFile the window auto close for few devloper.I have published a .exe file with runtime framework included, and distributed to other developer forβœ… Set Background color for one specific Row in GridI have a WPF project and a grid with a bunch of rows and columns. How can I change the background co❔ Facial recognition and centering using emgucv and arduino servos (visual studio)Hi guys, I am code illiterate. I found this code and need help because I do not know how to fix any ❔ Speech Recognizition makes me wanna cryI have already tried, using speech recogniztion on C++,Rust and now C#, since when this was that har❔ SystΓ¨me connexion wpfHello, Is someone making a connection system in wpf c# xaml to be simultaneously connected to my sitβœ… How to use SVGs in XAML file (WPF)I have a WPF project and I want to use an svg file in MainWindow.xaml. How do I properly use svg in