Why I'm having this error "Object of type 'System.UInt16' cannot be converted to type 'System.Int16" when I'm trying to run below code
public ActionResult List()
{
var x = account.All();
return View(x);
}
The errors showed up, when it's try to iterate my model in my List.aspx file (below code).
<% foreach (var item in Model) { %>
I'm using Subsonic 3.0.3 and MySQL database. Below is my account table descriptions
acc_id smallint(5) unsigned pri
acc_type smallint(5) unsigned
acc_status tinyint(3) unsigned
acc_balance int(11) unsigned
Do I have to modify something in MySQL.ttinclude to make this thing work?
Best Answer
Without knowing what
account.All()
orView(x)
do, that's pretty hard to know. It would have helped if you'd used explicit typing forx
as well.My guess is that something's unboxing to
short
instead ofushort
, but we can't really tell from just that bit of code. I assume this is an exception rather than a compile-time error? More information please!