954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem with soft delete

Hi all,

I have a field named 'UserDeleted' which is set to false by default. Records shouldnt be deleted from the database but the field Userdeleted should be set to true when user deletes a particular record.

when i click on delete button a gridview is shown with delete commanfield and other details. If i press this delte button then the data gets delted from the databse, which i dnt want. instead whenever i select a row the Userdeleted field should be set to true and a message should be displayed tht the user is deleted.


Thanks in advance.

ArchanaB
Newbie Poster
4 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

again. I am not to clear about what exactly you are saying. But if you create a DataGrid it usually create its won functions for Add, Update and Delete (the DataGrid CRUD methods). you can do one of 2 things:

1. remove the ability to delete using the datagrid controls
2. edit the control methods themselves to do what you want them to do.

If that was your problem I hope it helps. But usually if you post code it makes things alot easier to help you out with your problem.

8-D

mike.mclennan
Light Poster
45 posts since May 2007
Reputation Points: 39
Solved Threads: 0
 

Hi mike..

Am using visual web developer 2005 express and sql server management studio express for developing an intranet application.

u r rite datagrid creates itz own add,update and delete functions.
Whenever a user selects a row in the datagrid, then that should be logically deleted. .i.e. UserDeleted field in the database should be set to 'true' which was 'false' by default before.

Hope u got it what i want to tell..


Code goes here:


May be the problem seems small, but am ignorant about the code.

The query tht is highlighted with red color is giving problem i think.
Thanks a lot for the reply.

Please let me know where i have gone wrong.

ArchanaB
Newbie Poster
4 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

I am still not 100% on what you are trying to do. sorry I am really trying to understand but i found something that caught my eye. Maybe it will help

SelectCommand="SELECT UserName, LoginId, Email, MobileNo, UserAccess FROM Login_Tab WHERE (UserDeleted = 'False')" UpdateCommand="UPDATE Login_Tab SET UserDeleted = 'False' WHERE (LoginId = LoginId)">
    </asp: sqlDataSource>
  
</asp:Content>

<script runat=server >
    Dim constr As String
    Dim cmd As SqlCommand
    Dim con As SqlConnection
    Dim sql As String
    Dim re As SqlDataReader
    
Protected Sub select_click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs)
       
        
         sql = "update Login_Tab set UserDeleted='True' where LoginId= @LoginId "


If you notice you have 2 update commands which are doing the opposite of each other, one is setting the value to true, the other is setting the value to false. Maybe that is what it is suppose to do, but it does not seem to fit. Hope this helps.

mike.mclennan
Light Poster
45 posts since May 2007
Reputation Points: 39
Solved Threads: 0
 

Hi mike,

Thanks for the reply i will try out tht.

ArchanaB
Newbie Poster
4 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You