DataTables Editor - Upload not working

DataTables Editor - Upload not working

Ali AdnanAli Adnan Posts: 47Questions: 18Answers: 1

Dear Allan,

I am just running the Upload Example from the downloaded Project (.Net version).

I am getting this error "Object reference not set to an instance of an object."

Please see the screen shot, kindly guide me what I am missing ?

Ajax load (tab)

{
  "draw": null,
  "data": [
    {
      "DT_RowId": "row_43",
      "image": null,
      "first_name": "Ali",
      "last_name": "Adnan",
      "phone": null,
      "city": null
    },
    {
      "DT_RowId": "row_61",
      "image": null,
      "first_name": "ALI",
      "last_name": "ADNAN",
      "phone": "9999999999",
      "city": "KARACHI"
    }
  ],
  "recordsTotal": null,
  "recordsFiltered": null,
  "error": null,
  "fieldErrors": [],
  "id": null,
  "meta": {},
  "options": {},
  "files": {
    "files": {}
  },
  "upload": {
    "id": null
  },
  "debugSql": [
    {
      "Query": "SELECT  id as \"id\", image as \"image\", first_name as \"first_name\", last_name as \"last_name\", phone as \"phone\", city as \"city\" FROM  users ",
      "Bindings": []
    },
    {
      "Query": "SELECT  id as \"id\", web_path as \"web_path\", system_path as \"system_path\", filename as \"filename\", filesize as \"filesize\" FROM  files ",
      "Bindings": []
    }
  ],
  "cancelled": []
}

Ajax data (tab)

Submitted data:

action=create
data[0][first_name]=ALI
data[0][last_name]=ADNAN
data[0][phone]=9999999999
data[0][city]=KARACHI
data[0][image]=

Server response:

{
  "draw": null,
  "data": [
    {
      "DT_RowId": "row_61",
      "image": null,
      "first_name": "ALI",
      "last_name": "ADNAN",
      "phone": "9999999999",
      "city": "KARACHI"
    }
  ],
  "recordsTotal": null,
  "recordsFiltered": null,
  "error": null,
  "fieldErrors": [],
  "id": null,
  "meta": {},
  "options": {},
  "files": {},
  "upload": {
    "id": null
  },
  "debugSql": [
    {
      "Query": "INSERT INTO  users  ( image, first_name, last_name, phone, city ) VALUES (  :image,  :first_name,  :last_name,  :phone,  :city ) RETURNING id INTO :dtvalue",
      "Bindings": [
        {
          "Name": ":image",
          "Value": null,
          "Type": null
        },
        {
          "Name": ":first_name",
          "Value": "ALI",
          "Type": null
        },
        {
          "Name": ":last_name",
          "Value": "ADNAN",
          "Type": null
        },
        {
          "Name": ":phone",
          "Value": 9999999999,
          "Type": null
        },
        {
          "Name": ":city",
          "Value": "KARACHI",
          "Type": null
        }
      ]
    },
    {
      "Query": "SELECT  id as \"id\", image as \"image\", first_name as \"first_name\", last_name as \"last_name\", phone as \"phone\", city as \"city\" FROM  users WHERE id = :where_0 ",
      "Bindings": [
        {
          "Name": ":where_0",
          "Value": "61",
          "Type": null
        }
      ]
    },
    {
      "Query": "SELECT  id as \"id\", web_path as \"web_path\", system_path as \"system_path\", filename as \"filename\", filesize as \"filesize\" FROM  files ",
      "Bindings": []
    }
  ],
  "cancelled": []
}

Answers

  • Ali AdnanAli Adnan Posts: 47Questions: 18Answers: 1

    Dear Allan,

    I am trying to debug and found that the error is through by this line

    return _query._stmt.Parameters[":dtvalue"].Value.ToString();

    namespace DataTables.DatabaseUtil.Oracle
    
    Result.cs
    
    override public string InsertId()
            {
                // The Query will have set up a 
                return _query._stmt.Parameters[":dtvalue"].Value.ToString();
            }
    
    

    After debuging I found that below code never execute as the _pkey always get null

    namespace DataTables.DatabaseUtil.Oracle
    Query.cs
    
    // Need to reliably get the primary key value
                if (_type == "insert" && _pkey != null)
                {
                    // Add a returning parameter statement into an output parameter
                    sql += " RETURNING " + _pkey[0] + " INTO :dtvalue";
                }
    
    
    // Need to reliably get the primary key value
                if (_type == "insert" && _pkey != null)
                {
                    var outParam = cmd.CreateParameter();
                    outParam.ParameterName = ":dtvalue";
                    outParam.Direction = ParameterDirection.Output;
                    outParam.DbType = DbType.Int32;
    
                    cmd.Parameters.Add(outParam);
                    cmd.UpdatedRowSource = UpdateRowSource.OutputParameters;
                }
    
    

    as I already open a discussion https://datatables.net/forums/discussion/43445/insert-return-value-datatype-only-allowed-int-data-type#latest

    and you comment that you will do this and I am sure it will solve this problem.

    Please update

    Best Regards

  • Ali AdnanAli Adnan Posts: 47Questions: 18Answers: 1

    Dear Allan,
    There is one more issue which is after uploading the file it will display the uploaded file in "LightBox Editor", but if we select the table row and edit the same record the attached file disappeared,

    please see the data returned after upload

    {"draw":null,"data":[],"recordsTotal":null,"recordsFiltered":null,"error":null,"fieldErrors":[],"id":null,"meta":{},"options":{},"files":{"si_attchment":{"10":{"seq_id":10.0,"web_path":"\\Documents\\CCTR\\10.png","system_path":"D:\\Working\\VisualStudio\\V2015\\MZEC\\PortalUI\\Documents\\CCTR\\10.png","filename":"2017-07-12_16-35-57.png","filesize":85727.0}}},"upload":{"id":"10"},"debugSql":null,"cancelled":[]}
    
    

    please see the data in edit mode but not display in editor i kept only file node below

    {"draw":null,"data":[{"DT_RowId":"row_1","si_prlm_finl":,{"value":"ZUK","label":"ZUKEIT S/S"}]},"files":{"si_attchment":{"1":{"seq_id":1.0,"web_path":"\\Documents\\CCTR\\1.png","system_path":"D:\\Working\\VisualStudio\\V2015\\MZEC\\PortalUI\\Documents\\CCTR\\1.png","filename":"2017-07-12_16-36-59.png","filesize":249164.0},"2":{"seq_id":2.0,"web_path":"\\Documents\\CCTR\\2.png","system_path":"D:\\Working\\VisualStudio\\V2015\\MZEC\\PortalUI\\Documents\\CCTR\\2.png","filename":"JoinArrayPermission.png","filesize":208891.0},"3":{"seq_id":3.0,"web_path":"\\Documents\\CCTR\\3.png","system_path":"D:\\Working\\VisualStudio\\V2015\\MZEC\\PortalUI\\Documents\\CCTR\\3.png","filename":"2017-07-09_8-21-30.png","filesize":73806.0},"4":{"seq_id":4.0,"web_path":"\\Documents\\CCTR\\4.png","system_path":"D:\\Working\\VisualStudio\\V2015\\MZEC\\PortalUI\\Documents\\CCTR\\4.png","filename":"2017-07-12_16-36-59.png","filesize":249164.0},"5":{"seq_id":5.0,"web_path":"\\Documents\\CCTR\\5.png","system_path":"D:\\Working\\VisualStudio\\V2015\\MZEC\\PortalUI\\Documents\\CCTR\\5.png","filename":"2017-07-12_16-36-59.png","filesize":249164.0},"6":{"seq_id":6.0,"web_path":"\\Documents\\CCTR\\6.png","system_path":"D:\\Working\\VisualStudio\\V2015\\MZEC\\PortalUI\\Documents\\CCTR\\6.png","filename":"2017-07-09_8-21-55.png","filesize":58397.0},"7":{"seq_id":7.0,"web_path":"\\Documents\\CCTR\\7.png","system_path":"D:\\Working\\VisualStudio\\V2015\\MZEC\\PortalUI\\Documents\\CCTR\\7.png","filename":"2017-07-09_8-21-30.png","filesize":73806.0},"8":{"seq_id":8.0,"web_path":"\\Documents\\CCTR\\8.pdf","system_path":"D:\\Working\\VisualStudio\\V2015\\MZEC\\PortalUI\\Documents\\CCTR\\8.pdf","filename":"PaySlip_May2017.pdf","filesize":202747.0}}},"upload":{"id":null},"debugSql":null,"cancelled":[]}
    

    Please see the images

    Further the Relation("si_attch_rel") Table is empty the record is inserting only in master table
    My controller code is

    .MJoin(new MJoin("si_attchment")
                            .Link("si_prlm_finl.seq_id", "si_attch_rel.p_f_id")
                            .Link("si_attchment.seq_id", "si_attch_rel.attch_id")
                            .Field(
                                new Field("seq_id").Set(false)
                                    .Upload(new Upload(request.PhysicalApplicationPath + @"Documents\CCTR\__ID____EXTN__")
                                        .Db("si_attchment", "seq_id", new Dictionary<string, object>
                                        {
                                            {"web_path", DataTables.Upload.DbType.WebPath},
                                            {"system_path", DataTables.Upload.DbType.SystemPath},
                                            {"filename", DataTables.Upload.DbType.FileName},
                                            {"filesize", DataTables.Upload.DbType.FileSize}
                                        })
                                    )
                            )
                        )
    
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    When posting screenshots, it is helpful to describe what each one represents.

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Hi,

    Yes, it does appear that the file upload is broken with Oracle at the moment I'm afraid. I'll be looking into that. Thanks for letting me know.

    Regards,
    Allan

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Just a quick one to say that this now has the required fix committed and it will be in 1.6.4 which will drop soon.

    I'm still working on the string primary key issue and will update that thread with progress there.

    Allan

This discussion has been closed.