editor is not updating sql table

editor is not updating sql table

wijwijwijwij Posts: 54Questions: 12Answers: 0
edited July 2021 in DataTables

Hi,
I have deployed my .net application to a local folder and when I tried to add a new record to one of my datatables, it shows the newly added record in the running app but when I checked the SQL table, I couldn't find this new record. Also, I am not getting any error
Am I missing anything here?
Appreciate your help

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    That's odd. If you refresh the table, does the newly created record get removed?

    Colin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0

    no
    What is even strange is that I can see the new record in the running app in the browser but no in the SQL table. Where it comes from then?

  • kthorngrenkthorngren Posts: 21,262Questions: 26Answers: 4,934

    How are you creating the new record?

    Kevin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0

    by using the editor
    The editor is using the controllers and models (.net environment)
    The problem is that it works perfectly when deploying the application into the internet but when deploying to the local folder; it is stopped updating the database
    I have checked the database connectivity in the properties/settings and in the web.config and they are all refers to the local database

    Not sure what I am missing?
    And there is no error message whatsoever

  • kthorngrenkthorngren Posts: 21,262Questions: 26Answers: 4,934

    When Editor creates a new record it expects this request/response pattern:
    https://editor.datatables.net/manual/server#Create

    You can look at your browser's network inspector tool to see what is sent and returned.

    If you reload the web page is the new record in the web page?

    Kevin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0
    edited July 2021

    If you reload the web page is the new record in the web page?
    Also, when I made any change to the records, it won't be reflected in the database table
    It is not the "create" per se

    Yes!

  • kthorngrenkthorngren Posts: 21,262Questions: 26Answers: 4,934

    Sounds like its added to your database table. Are you sure your Datatables and Editor ajax options are pointing to your local script?

    Kevin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0

    yes

  • kthorngrenkthorngren Posts: 21,262Questions: 26Answers: 4,934

    All I can suggest is to enable debugging in your server script and trace what happens with the create request. Its being saved somewhere if the data shows in the Datatable. If you need help with this then work with Allan or Colin to give them access to your server/localhost so the can help trace what is happening.

    Kevin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0

    Thank you Kevin
    Thank you Colin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0

    Thought to add this note just in case someone can help further
    When I use "Postman" to test the API, it shows the newly added record

    GET localhost:8080/api/manf

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Yep, because the page refresh still shows the record, it means the record is in the database, otherwise it wouldn't be returned. The Editor scripts aren't caching anything, so every page refresh is actually hitting the database.

    I would check your local query when you report that it's not in the database. Given it must be in there, either your script is accessing the wrong database or table, or you're just missing it in the output.

    Colin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0

    Thanks, Colin for your comments.
    Actually, I tested the database from another web page in the application and it seems connected to the database
    Also, I am not very much familiar with the controllers/models architecture. So, the Controllers and Models folders need to be included in the published/deployed solution...right?
    I am trying to find what is causing this bug

    Thanks

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Yep, they'll need to be there. If they weren't, you would get an error from Editor, and as you aren't, and as a page refresh shows the expected data, Editor is definitely storing the records somewhere, and DataTables is reading back from the same source.

    The best bet would be to look at the PHP script that DataTables uses to load the data, and see where it's reading the data from,

    Colin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0
    edited July 2021

    Thanks, Colin for directing me in the right direction
    This is what I found:
    The update has been sent to the live website database and not to the local server database
    That's why I am not getting any errors and that's why the API test in Postman returns the newly added record

    The strange thing is I have set up the connection to the local server everywhere in the application but I can't find where it connects to the live database

    By the way: when I added new records to other pages that are not using the Datatables and controllers/models and found that the new record had been added to the database,
    it is only when I add a new record in the data tables pages, it goes to the live database.

    Is there a place other than the properties.settings to set the connectivity to the database?

    Not sure where to look at in my application to modify the database connectivity to the local one
    Once again, thank you Colin

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    The database connection is specified in lib/config.php.

    Colin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0

    Thanks Colin,
    I am using .net environment not php

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Take a look at Properties/Settings.settings, you need to set the DbConnection string,

    Colin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0

    I already did this from the beginning :( :(

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You did, and it's writing to a location, but you said earlier that it's writing to the wrong place:

    The strange thing is I have set up the connection to the local server everywhere in the application but I can't find where it connects to the live database

    So you'll need to configure Editor to write to the live database, and that file is where the connection information is provided,

    Colin

  • wijwijwijwij Posts: 54Questions: 12Answers: 0
    edited July 2021

    Colin. I don't want it to write to the live database. instead, I want it to write to the local sql db
    Can you please guide me about how to configure the Editor to write to the local database?

    Thank you

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin

    Hi,

    Colin has asked me to take a look at the problem you are having here.

    Can you show me the controller code you are using please? I'm assuming you are using our .NET libraries for Editor? When you create the new Database() class instant, you need to pass in a connection string (or an already established database connection).

    It is that connection string that defines what database Editor will connect to for the CRUD operations.

    In our example packages we have a DbConnection string in the Settings.settings file - you may be using something else for it?

    Either way, I would suggest you put a breakpoint at the point where you create the new Database() instance and check what its value is, and that it is pointing to the database you actually want to write to.

    Allan

Sign In or Register to comment.