微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

LINQ字符串不正确

如何解决LINQ字符串不正确

这是我的存储过程代码错误是输入字符串不正确。 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 举报,一经查实,本站将立刻删除。