Error running the Edit table example.

Error running the Edit table example.

mbianco21mbianco21 Posts: 3Questions: 1Answers: 0

With the Edit table, I am trying to run samples with SQLite. First, there are errors running the sql script. Fixed that. Second, there are errors with "var provider = DbProviderFactories.GetFactory(Adapter()); in Database.cs" Fixed that by hard coding the connection string to my SQlite DB. Now, I get the following error at the browser (http://localhost:49942/api/staff?_=1484082959664).

I have been at setting up the sample for hours. Am I missing something? Simple is killing me. Anyone have any thoughts? Thank you.

{draw: null, data: [], recordsTotal: null, recordsFiltered: null,…}
cancelled:[]
data:[]
debugSql:null
draw:null
error:"String was not recognized as a valid DateTime."
fieldErrors:[]
files:{}
id:null
meta:{}
options:{}
recordsFiltered:null
recordsTotal:null
upload:{id: null}

Answers

  • allanallan Posts: 63,839Questions: 1Answers: 10,518 Site admin

    Sorry you are having problems with this.

    Do you have a DateTime in your model? If so, could you change it to be a string please? The models need to have only string, int or decimal data types.

    Allan

  • mbianco21mbianco21 Posts: 3Questions: 1Answers: 0

    Thank you for your response. I have not modified the Models. Here is where the error occurs first, I believe. The return text is "String was not recognized as a valid DateTime." I have attempted to run the examples "at is." Are you able to successfully download and run the examples? I am I missing something? Thanks again for help.

    public class StaffController : ApiController
    {
        [Route("api/staff")]
        [HttpGet]
        [HttpPost]
        public IHttpActionResult Staff()
        {
            var request = HttpContext.Current.Request;
            var settings = Properties.Settings.Default;
    
            using (var db = new Database(settings.DbType, settings.DbConnection))
            {
                var response = new Editor(db, "datatables_demo")
                    .Model<StaffModel>()
                    .Field(new Field("first_name")
                        .Validator(Validation.NotEmpty())
                    )
                    .Field(new Field("last_name"))
                    .Field(new Field("extn")
                        .Validator(Validation.Numeric())
                    )
                    .Field(new Field("age")
                        .Validator(Validation.Numeric())
                        .SetFormatter(Format.IfEmpty(null))
                    )
                    .Field(new Field("salary")
                        .Validator(Validation.Numeric())
                        .SetFormatter(Format.IfEmpty(null))
                    )
                    .Field(new Field("start_date")
                        .Validator(Validation.DateFormat(
                            Format.DATE_ISO_8601,
                            new ValidationOpts { Message = "Please enter a date in the format yyyy-mm-dd" }
                        ))
                        .GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
                        .SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
                    )
                    .Process(request)
                    .Data();
    
                return Json(response);
            }
        }
    }
    

    }

  • allanallan Posts: 63,839Questions: 1Answers: 10,518 Site admin

    This is the basic simple example? Do all the others also report errors for you?

    I haven't seen that issue myself I'm afraid.

    If you add .TryCatch(false) between lines 13 and 14 in the above code, it will hopefully show a little more information about where the error is occurring exactly.

    Thanks,
    Allan

  • mbianco21mbianco21 Posts: 3Questions: 1Answers: 0

    Yes, all the examples error this way. Appreciate the help. I moved away from SQlite as I can't spend any more time troubleshooting the examples (see first post). I moved to MySql, which is what we use for our PRD app anyway, and the examples work just great. Although, there are errors running the database script provided. Love the Edit Table, Good stuff. Thanks again.

  • allanallan Posts: 63,839Questions: 1Answers: 10,518 Site admin

    Thanks for highlighting this. I'll look into it for the next release and see if I can figure out what might be going wrong.

    Regards,
    Allan

This discussion has been closed.