locked
Can't Delete Records from DB RRS feed

  • Question

  • So, first all.....thanks eveyone for the assitance so far.  My application is coming along and for the first time yesterday I publish my LS app to do some testing.

    My problem today is now I can't delete records.  I'm working on my app on my machine and it's attached to an external database.   I can't delete records, although I can add and edit records on the development machine.  Now that I have the application where I want it and it published ok, I was now trying to add permissions......they wen't working the way that I wanted so I removed all code for the permissions and this is where I'm running into my problem of not being able to delete records.  I changed the access control back to not requiring authentication and still not working.  Does anyone have any suggests of what I might try?

    If I use the LS app that I've publish to my site before I tried to make the permissions it does work correctly

    Thursday, February 21, 2013 3:29 PM

Answers

  • This actually isn't a bug.

    When you override the delete button with your own code, LightSwitch generates a new method on the screen and replaces the button with a new one that is bound to that method. You can see that the button is bound to your custom method when you select the button and inspect the Data Binding property in the property sheet. If you don't write any code for that method, then the button won't do anything. Removing the <MethodName>_CanExecute and <MethodName>_Execute methods from your user code does not magically make the button do what it did previous to your custom changes.

    As you have found out, to revert to the built-in behavior, you have to delete your button and add new new one that is bound to the correct method (e.g. the delete method on a visual collection).


    Justin Anderson, LightSwitch Development Team

    • Proposed as answer by Yann DuranModerator Friday, February 22, 2013 12:35 PM
    • Marked as answer by Angie Xu Monday, March 11, 2013 12:50 AM
    Friday, February 22, 2013 3:31 AM
    Moderator

All replies

  • To add more:  It's almost like the delete button on the LS program is working.  I'm able to click it but nothing happens.  I did previously write code so that the button was disabled if the user didn't have permission, however, I've taken away every bit of code from my program and turned off access control.

    Thursday, February 21, 2013 5:38 PM
  • I just found my problem.  It looks like there might be a bug in the LS program.  On my list I had a delete button (a standard button, nothing custom).  It was working and then I added code to the button to hide it if the user didn't have persmission to delete the record.  When things wern't working out for me I decided to delete the permission code from the button, from that point on I couldn't delete a selected record.  I did remove all the code from the button, so I acutally just removed the delete button from the screen, saved the project, then re-added the delete button again and it works fine.

    Is there a way that I can subit this to Microsoft as a possible bug in the program?

    Thursday, February 21, 2013 8:25 PM
  • Hi,

    To submit a bug, you would go to the Microsoft Connect website.

    I think what is happening is that when you wrote the custom code it overwrote what the default method the button used did.

    If you submit all the steps it takes to duplicate it to connect, we can see whats going on.

    Thanks

    Pierson


    Thursday, February 21, 2013 9:04 PM
    Moderator
  • Hi,

    With the info provided it will be difficult to assist. So I'm afraid that I will asking questions:

    • Do you get any exceptions? Which you may have caught which would stop them displaying.
    • Are you using one of the standard delete buttons from LS or a custom button?

    If you are using a standard button try removing the button and methods, then add the button back.

    You could try using Fiddler to see if there is any communications between the client and the server.

    Friday, February 22, 2013 3:11 AM
  • This actually isn't a bug.

    When you override the delete button with your own code, LightSwitch generates a new method on the screen and replaces the button with a new one that is bound to that method. You can see that the button is bound to your custom method when you select the button and inspect the Data Binding property in the property sheet. If you don't write any code for that method, then the button won't do anything. Removing the <MethodName>_CanExecute and <MethodName>_Execute methods from your user code does not magically make the button do what it did previous to your custom changes.

    As you have found out, to revert to the built-in behavior, you have to delete your button and add new new one that is bound to the correct method (e.g. the delete method on a visual collection).


    Justin Anderson, LightSwitch Development Team

    • Proposed as answer by Yann DuranModerator Friday, February 22, 2013 12:35 PM
    • Marked as answer by Angie Xu Monday, March 11, 2013 12:50 AM
    Friday, February 22, 2013 3:31 AM
    Moderator