Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Datatable和Mysql错误:搜索的值不能为空。如果有';如果未执行搜索,请提供空字符串。_Jquery_Mysql_Asp.net Mvc_Datatable - Fatal编程技术网

Jquery Datatable和Mysql错误:搜索的值不能为空。如果有';如果未执行搜索,请提供空字符串。

Jquery Datatable和Mysql错误:搜索的值不能为空。如果有';如果未执行搜索,请提供空字符串。,jquery,mysql,asp.net-mvc,datatable,Jquery,Mysql,Asp.net Mvc,Datatable,我正在从事一个使用ASP NET MVC5和MYSQL的项目 我试图创建一个数据表来显示客户端。但我在这个问题上犯了错误 在Begging,我创建了控制器、模型和视图,但无法跟踪错误。最后,我只构建了控制器和模型,使用POSTMAN,我发现有些东西不起作用 这是我的模型 using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations

我正在从事一个使用ASP NET MVC5和MYSQL的项目

我试图创建一个数据表来显示客户端。但我在这个问题上犯了错误

在Begging,我创建了控制器、模型和视图,但无法跟踪错误。最后,我只构建了控制器和模型,使用POSTMAN,我发现有些东西不起作用

这是我的模型

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

namespace AseguradorasWeb.Models
{
    [Table("clientes")]
    public class cliente
    {

        [Key]
        public int ID_Cliente { get; set; }

        [StringLength(60)]
        [Required(ErrorMessage = "El campo {0} es mandatorio")]
        [Index("NombreIndex")]
        [Display (Name = "Nombre")]
        public string NOM_Cliente { get; set; }

        [StringLength(60)]
        [Required(ErrorMessage = "El campo {0} es mandatorio")]
        [Index("ApellidoIndex")]
        [Display(Name = "Apellido")]
        public string APE_Cliente { get; set; }

        [StringLength(16)]
        [Display(Name = "RFC")]
        public string RFC_Cliente { get; set; }

        [StringLength(100)]
        [DataType(DataType.EmailAddress)]
        [Display(Name = "Email")]
        public string EMAIL_Cliente { get; set; }

        [StringLength(12)]
        [Display(Name = "Teléfono Casa")]
        public string TEL_CASA_Cliente { get; set; }

        [StringLength(12)]
        [Display(Name = "Teléfono Celular")]
        public string TEL_CEL_Cliente { get; set; }

        [StringLength(200)]
        [Display(Name = "Calle")]
        public string CALLE_NUM_Cliente { get; set; }

        [StringLength(50)]
        [Display(Name = "Colonia")]
        public string COLONIA_Cliente { get; set; }

        [StringLength(50)]
        [Display(Name = "Ciudad")]
        public string CIUDAD_Cliente { get; set; }

        [StringLength(30)]
        [Display(Name = "Estado")]
        public string EDO_Cliente { get; set; }

        [StringLength(200)]
        [Display(Name = "Dirección Oficina")]
        public string DIR_OFIC_Cliente { get; set; }

        [StringLength(12)]
        [Display(Name = "Teléfono Oficina")]
        public string TEL_OFIC_Cliente { get; set; }

        [StringLength(50)]
        [Display(Name = "Nombre Contacto")]
        public string NOM_CONTAC_Cliente { get; set; }

        [StringLength(12)]
        [Display(Name = "Teléfono Contacto")]
        public string TEL_CONTAC_Cliente { get; set; }

        [StringLength(12)]
        [Display(Name = "Celular Contacto")]
        public string CEL_CONTAC_Cliente { get; set; }


        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
        [Display(Name = "Fecha Nacimiento")]
        public DateTime FEC_NAC_Cliente { get; set; }

        [StringLength(1)]
        [Display(Name = "Sexo")]
        public string SEXO_Cliente { get; set; }

        [StringLength(1)]
        [Display(Name = "Inactivo")]
        public string Inactivo_Cliente { get; set; }

        [DataType(DataType.MultilineText)]
        [Display(Name = "Observaciones")]
        public string Observaciones_Cliente { get; set; }

        [NotMapped]
        public string FullName { get { return string.Format("{0} {1}", NOM_Cliente ?? string.Empty, APE_Cliente ?? string.Empty).Trim(); } }

        [JsonIgnore]
        public virtual ICollection<cliente_poliza> cliente_poliza { get; set; }

    }
}

Información de version:version de Microsoft.NET Framework:4.0.30319;ASP.NET版本:4.6.1099.0 我正在使用visual studio 2015 Datatables.mvc5版本0.1.0 jquery.datatables版本1.10.15

你能告诉我怎么了吗


当我提到ASPNET和MVC5上的新功能时,谢谢

我发现了问题

我没有从INDEX方法运行视图,而是直接从GET方法运行

一旦我将视图结构更改为视图索引,并从那里调用GET方法。我让它工作


当我提到ASPNET和MVC5上的新功能时,干杯

我发现了问题

我没有从INDEX方法运行视图,而是直接从GET方法运行

一旦我将视图结构更改为视图索引,并从那里调用GET方法。我让它工作


Cheers

搜索的值不能为空。如果未执行任何搜索,请提供一个空字符串
这一点不言自明-是否将
NULL
作为搜索参数传递?您可以改为传递空字符串吗?
搜索的值不能为null。如果未执行任何搜索,请提供一个空字符串
这一点不言自明-是否将
NULL
作为搜索参数传递?你能传递一个空字符串吗?
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using AseguradorasWEB.Models;
using AseguradorasWeb.Models;
using DataTables.Mvc;
using System.Linq.Dynamic;

namespace AseguradorasWEB.Controllers
{
    public class clientesController : Controller
    {
        private AseguradorasWEBContext db = new AseguradorasWEBContext();


        public ActionResult Get([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            IQueryable<cliente> query = db.clientes;

            var totalCount = query.Count();

            #region Filtering
            // Apply filters for searching
            if (requestModel.Search.Value != string.Empty)
            {
                var value = requestModel.Search.Value.Trim();
                query = query.Where(p => p.NOM_Cliente.Contains(value) ||
                                         p.APE_Cliente.Contains(value)

                                   );
            }


            var filteredCount = query.Count();

            #endregion Filtering

            #region Sorting
            // Sorting
            var sortedColumns = requestModel.Columns.GetSortedColumns();
            var orderByString = String.Empty;

            foreach (var column in sortedColumns)
            {
                orderByString += orderByString != String.Empty ? "," : "";
                orderByString += (column.Data) +
                  (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
            }

            query = query.OrderBy(orderByString == string.Empty ? "Nombre asc" : orderByString);

            #endregion Sorting

            // Paging
            query = query.Skip(requestModel.Start).Take(requestModel.Length);

            var data = query.Select(cliente => new
            {
                Nombre = cliente.NOM_Cliente,
                Apellido = cliente.APE_Cliente
            }).ToList();

            return Json(new DataTablesResponse
            (requestModel.Draw, data, filteredCount, totalCount),
                        JsonRequestBehavior.AllowGet);
        }
<!DOCTYPE html>
<html>
    <head>
        <title>The value of the search cannot be null. If there's no search performed, provide an empty string.
            <br>Nombre del par&#225;metro: value
        </title>
        <meta name="viewport" content="width=device-width" />
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
         @media screen and (max-width: 639px) {
          pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
         }
         @media screen and (max-width: 479px) {
          pre { width: 280px; }
         }
        </style>
    </head>
    <body bgcolor="white">
        <span>
            <H1>Error de servidor en la aplicación '/'.
                <hr width=100% size=1 color=silver>
            </H1>
            <h2>
                <i>The value of the search cannot be null. If there's no search performed, provide an empty string.
                    <br>Nombre del par&#225;metro: value
                </i>
            </h2>
        </span>
        <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
            <b> Descripción: </b>Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.
            <br>
            <br>
            <b> Detalles de la excepción: </b>System.ArgumentNullException: The value of the search cannot be null. If there's no search performed, provide an empty string.
            <br>Nombre del par&#225;metro: value
            <br>
            <br>
            <b>Error de código fuente:</b>
            <br>
            <br>
            <table width=100% bgcolor="#ffffcc">
                <tr>
                    <td>
                        <code>

Se ha generado una excepci&#243;n no controlada durante la ejecuci&#243;n de la solicitud Web actual. La informaci&#243;n sobre el origen y la ubicaci&#243;n de la excepci&#243;n pueden identificarse utilizando la excepci&#243;n del seguimiento de la pila siguiente.</code>
                    </td>
                </tr>
            </table>
            <br>
            <b>Seguimiento de la pila:</b>
            <br>
            <br>
            <table width=100% bgcolor="#ffffcc">
                <tr>
                    <td>
                        <code>
                            <pre>

[ArgumentNullException: The value of the search cannot be null. If there&#39;s no search performed, provide an empty string.
Nombre del par&#225;metro: value]
   DataTables.Mvc.Search..ctor(String value, Boolean isRegexValue) +97
   DataTables.Mvc.DataTablesBinder.Bind(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +300
   DataTables.Mvc.DataTablesBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +34
   System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +330
   System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +105
   System.Web.Mvc.Async.&lt;&gt;c__DisplayClass21.&lt;BeginInvokeAction&gt;b__19(AsyncCallback asyncCallback, Object asyncState) +743
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +14
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +343
   System.Web.Mvc.Controller.&lt;BeginExecuteCore&gt;b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +465
   System.Web.Mvc.Controller.&lt;BeginExecute&gt;b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
   System.Web.Mvc.MvcHandler.&lt;BeginProcessRequest&gt;b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +384
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155
</pre>
                        </code>
                    </td>
                </tr>
            </table>
            <br>
            <hr width=100% size=1 color=silver>
            <b>Información de versión:</b>&nbsp;Versión de Microsoft .NET Framework:4.0.30319; Versión ASP.NET:4.6.1099.0
        </font>
    </body>
</html>
<!-- 
[ArgumentNullException]: The value of the search cannot be null. If there&#39;s no search performed, provide an empty string.
Nombre del par&#225;metro: value
   en DataTables.Mvc.Search..ctor(String value, Boolean isRegexValue)
   en DataTables.Mvc.DataTablesBinder.Bind(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
   en DataTables.Mvc.DataTablesBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
   en System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor)
   en System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
   en System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState)
   en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
   en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
   en System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state)
   en System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState)
   en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
   en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
   en System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state)
   en System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller)
   en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
   en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
   en System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)
   en System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)
   en System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState)
   en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState)
   en System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
   en System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
   en System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
   en System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
   en System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   en System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->