C
C#5mo ago
Yasaki Kondo

I need help asap

I don't know what I'm doing wrong here, My laptop can run it but my desktop weren't able to run it, does using different browser affect something?
No description
7 Replies
Jimmacle
Jimmacle5mo ago
this error is coming from your database, it's telling you that there is no table called "Students" if you're using a different database make sure you've run your migrations, etc.
Yasaki Kondo
Yasaki KondoOP5mo ago
damn I should've checked :/
No description
Yasaki Kondo
Yasaki KondoOP5mo ago
but edit and delete doesn't seem to work :/
No description
No description
Jimmacle
Jimmacle5mo ago
you'll need to use the debugger and do some troubleshooting to identify the problem that error is telling you that the value of Find is null which would be the case if your id is not the ID of an entity in the students table
Yasaki Kondo
Yasaki KondoOP5mo ago
well it seems like it can't find the ID :/ both the delete and edit function @Jimmacle
C#
public IActionResult Update(Guid id)
{
var Find = _db.Students.FirstOrDefault(x => x.Id == id);
return View(Find);
}
[HttpPost]
public IActionResult Update(Student st)
{
_db.Students.Update(st);
_db.SaveChanges();
return RedirectToAction("List");
}
public IActionResult Delete(Guid id)
{
var Find = _db.Students.FirstOrDefault(x => x.Id == id);
_db.Students.Remove(Find);
_db.SaveChanges();
return RedirectToAction("List");
}
C#
public IActionResult Update(Guid id)
{
var Find = _db.Students.FirstOrDefault(x => x.Id == id);
return View(Find);
}
[HttpPost]
public IActionResult Update(Student st)
{
_db.Students.Update(st);
_db.SaveChanges();
return RedirectToAction("List");
}
public IActionResult Delete(Guid id)
{
var Find = _db.Students.FirstOrDefault(x => x.Id == id);
_db.Students.Remove(Find);
_db.SaveChanges();
return RedirectToAction("List");
}
here's the code, got any ideas?
Yasaki Kondo
Yasaki KondoOP5mo ago
the ID is still in here :/
No description
Yasaki Kondo
Yasaki KondoOP5mo ago
nvm I'm dumb
No description
Want results from more Discord servers?
Add your server