问题描述
这是我的存储过程代码,错误是输入字符串不正确。 LINQ字符串可能有错误。 谁能帮我指出错误。
public ActionResult TeacherDashboard()
{
List<AttendanceModel> data = new List<AttendanceModel>();
string constr = ConfigurationManager.ConnectionStrings["AttendanceConnect"].ToString();
DataTable dt = new DataTable();
using (sqlConnection con = new sqlConnection(constr))
{
using (sqlCommand cmd = new sqlCommand("getUserDetails",con))
{
using (sqlDataAdapter da = new sqlDataAdapter())
{
cmd.CommandType = CommandType.StoredProcedure;
da.SelectCommand = cmd;
con.open();
da.Fill(dt);
}
}
}
if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
{
data = (from DaTarow dr in dt.Rows
select new AttendanceModel()
{
UserId = Convert.ToInt32(dr["UserId"].ToString()),UserRole = dr["UserRole"].ToString(),Email = dr["Email"].ToString(),Password = dr["Password"].ToString(),Mobile = Convert.ToInt32(dr["Mobile"].ToString()),isActive = Convert.ToBoolean(dr["isActive"].ToString())
}).ToList();
}
return View(data.ToList());
}
这是我的查看代码,并尝试使用Jquery DataTable。但是代码停留在输入字符串上是不正确的,这是LINQ代码。有人可以帮助我知道我哪里出错了。
@model IEnumerable<AttendanceManagement.Models.AttendanceModel>
@{
ViewBag.Title = "TeacherDashboard";
}
<h2>Tables</h2>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<table id="attendanceUser" class="display">
<thead>
<tr>
<th>
@Html.displayNameFor(model => model.UserId)
</th>
<th>
@Html.displayNameFor(model => model.UserRole)
</th>
<th>
@Html.displayNameFor(model => model.Password)
</th>
<th>
@Html.displayNameFor(model => model.isActive)
</th>
<th>
@Html.displayNameFor(model => model.Email)
</th>
<th>
@Html.displayNameFor(model => model.Mobile)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.displayFor(modelItem => item.UserId)
</td>
</tr>
<tr>
<td>
@Html.displayFor(modelItem => item.UserRole)
</td>
</tr>
<tr>
<td>
@Html.displayFor(modelItem => item.Password)
</td>
</tr>
<tr>
<td>
@Html.displayFor(modelItem => item.isActive)
</td>
</tr>
<tr>
<td>
@Html.displayFor(modelItem => item.Email)
</td>
</tr>
<tr>
<td>
@Html.displayFor(modelItem => item.Mobile)
</td>
</tr>
<tr>
<td>
@Html.ActionLink("Edit","Edit",new { id = item.UserId }) |
@Html.ActionLink("Delete","Delete",new { id = item.UserId })
</td>
</tr>
}
</tbody>
</table>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.js"></script>
<script>
$(document).ready( function () {
$('#attendanceUser').DataTable();
});
</script>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)