Hello everybody,
I have an intranet application which is mostly a bunch of data editing
forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete
in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid
as I had no idea how.
How is this normally done in ASP.NET app?
Morgan 13 2363
I supposed this is not quite an ASP.NET related question, it's more database
related.
So you should tell us what database you're using.And if you're using MSSQL,
you'll get better chance being answered if you're posting in
microsoft.public.sqlserver.server newsgroup.
"Morgan Bachu" <ds********@tiscali.co.uk>
???????:11**********************@g14g2000cwa.googl egroups.com... Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan
Morgan Bachu wrote: Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan
If it's deleted from the database, then it is gone (no "recycle bin")!
Time to check if the backup procedure really works, I'm afraid.
Hans Kesting
What database is it ? Sql server, Access, ...
Let me know if you have any more questions...
Cheers,
Tom Pester Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan
I remember that if it's MS Access or so, when the record is deleted but not
packed, there's some change to recover...
"Hans Kesting" <ne***********@spamgourmet.com> ¼¶¼g©ó¶l¥ó·s»D:e5**************@TK2MSFTNGP15.phx.g bl... Morgan Bachu wrote: Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan
If it's deleted from the database, then it is gone (no "recycle bin")! Time to check if the backup procedure really works, I'm afraid.
Hans Kesting
What I would do is set up an identical set of tables, prefaced
"bk_thetablename" and store any records deleted in *that* set of tables.
Kind of like an audit trail.
That way, although you delete records,
you still keep all records, deleted or not, permanently.
Juan T. Llibre
ASP.NET MVP http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
"Morgan Bachu" <ds********@tiscali.co.uk> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan
In sql server you can undelete it by examening the transaction log. There
are tools to make it easy.
A general approuch it to take backups so you can go back in time or do the
undelete manualy with some copy & pasting.
Cheers,
Tom Pester Morgan Bachu wrote:
Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan If it's deleted from the database, then it is gone (no "recycle bin")! Time to check if the backup procedure really works, I'm afraid.
Hans Kesting
Or you could do a soft delete. When the user deletes a row you flip a switch
in a column, so :
delete from table where id = 8
becomes
update table set deleted = true
You can make it transparent for the developer by making a view of the table
like this :
Employees_All : a table that has also the deleted records
Employees : SELECT * FROM Employees where deleted = false
Let me know if you have any more questions...
Cheers,
Tom Pester What I would do is set up an identical set of tables, prefaced "bk_thetablename" and store any records deleted in *that* set of tables.
Kind of like an audit trail.
That way, although you delete records, you still keep all records, deleted or not, permanently. Juan T. Llibre ASP.NET MVP http://asp.net.do/foros/ Foros de ASP.NET en Español Ven, y hablemos de ASP.NET... ====================== "Morgan Bachu" <ds********@tiscali.co.uk> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...
Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan
Morgan,
This isn't so much of an ASP.NET question as it is an application design
question.
If an application I build allows the user to delete anything it is at most
only a logical delete. Basically I have a field in each table named
isDeleted. If set to true then that row is 'logically' deleted when it comes
to the application but the data is still there.
In one case I even created a Deleted Items page so the admins could go see
what's been deleted and 'un-delete' anything they wanted to.
"Morgan Bachu" wrote: Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan
That is a viable database design idea, too.
Juan T. Llibre
ASP.NET MVP http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
"tom pester" <To********************@pandora.be> wrote in message
news:a1***************************@news.microsoft. com... Or you could do a soft delete. When the user deletes a row you flip a switch in a column, so :
delete from table where id = 8 becomes update table set deleted = true
You can make it transparent for the developer by making a view of the table like this :
Employees_All : a table that has also the deleted records Employees : SELECT * FROM Employees where deleted = false
Let me know if you have any more questions...
Cheers, Tom Pester
What I would do is set up an identical set of tables, prefaced "bk_thetablename" and store any records deleted in *that* set of tables.
Kind of like an audit trail.
That way, although you delete records, you still keep all records, deleted or not, permanently. Juan T. Llibre ASP.NET MVP http://asp.net.do/foros/ Foros de ASP.NET en Español Ven, y hablemos de ASP.NET... ====================== "Morgan Bachu" <ds********@tiscali.co.uk> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...
Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan
Hi Morgan,
I have recently been trying to solve this problem too.
(I am assuming you are using SQL Server)
This is what I came up with:
Using "IsDeleted" type approach is OK but try and use a timestamp
so null = not deleted, not null = time of deletion
this enables you to purge records that really should be deleted
as they are only taking up space
the biggest problem with this approach is it doesn't work very well
for more complex schemas with cascade deleting etc.
it can work but it gets complicated very quickly
to solve this you can combine a table which logs the deletes with a
timestamp
a trigger on the tables you want to protect
and then a script that does a point in time restore of the database (to
a new database)
and then simply copies the records back
here is some example code:
--example table
create table LogDeletions (
LogID int primary key identity
, LogDate datetime not null default getdate()
, TableName varchar(255) not null
, RecordID int not null
)
-- example trigger
create trigger trAuditLogDelete
on auditlog
for delete
as
--
insert into LogDeletions (LogDate, TableName, RecordID)
select getdate(), 'AuditLog', AuditLogID
from deleted
--(end)
-- example point in time restore
drop database Recovery
go
restore database Recovery
from disk = 'filename of last full backup', norecovery
go
restore log Recovery
from disk = 'filename of suitable log file', stopat = '2005-05-05
12:01:32.435'
go
--example insert of related records
select primarykey into #temp1
from firstdependenttable where maintable.foreignkey = the one deleted
from the maintable
insert into originaldatabase.dbo.seconddep*endenttable
select *
from seconddependenttable
where firstdependenttable.foreignkey in (select primarykey from #temp1)
insert into originaldatabase.dbo.firstdepe*ndenttable
select *
from firstdependenttable
where primarykey in (select primarykey from #temp1)
insert into originaldatabase.dbo.maintable
select *
from maintable
where primarykey = the one deleted from the maintable
this isn't a fully automatic restore solution
but more of an accelerated disaster recovery
solution
i hope it helps,
it works fine for me
and, except for the triggers is "non-invasive"
ie: i didn't have to rewrite 100 queries etc.
All the best,
John Rivers
The most unobtrusive way I can come up with is the use a tool that scans
the transaction log and can selectively rollback certain transactions.
This requires no architectural changes.
There is actually a faq about it: http://www.aspfaq.com/show.asp?id=2449
These are the products that get mentioned in the article:
Apex SQL Log
Log Explorer
Log P.I.
SQL Log Rescue
Shortcomings:
- No web interface to let savvy site users do a rollback
Cheers,
Tom Pester Hi Morgan,
I have recently been trying to solve this problem too.
(I am assuming you are using SQL Server)
This is what I came up with:
Using "IsDeleted" type approach is OK but try and use a timestamp so null = not deleted, not null = time of deletion this enables you to purge records that really should be deleted as they are only taking up space the biggest problem with this approach is it doesn't work very well for more complex schemas with cascade deleting etc.
it can work but it gets complicated very quickly
to solve this you can combine a table which logs the deletes with a timestamp a trigger on the tables you want to protect and then a script that does a point in time restore of the database (to a new database) and then simply copies the records back here is some example code:
--example table
create table LogDeletions ( LogID int primary key identity , LogDate datetime not null default getdate() , TableName varchar(255) not null , RecordID int not null ) --example insert of related records
select primarykey into #temp1 from firstdependenttable where maintable.foreignkey = the one deleted from the maintable insert into originaldatabase.dbo.seconddep*endenttable select * from seconddependenttable where firstdependenttable.foreignkey in (select primarykey from #temp1) insert into originaldatabase.dbo.firstdepe*ndenttable select * from firstdependenttable where primarykey in (select primarykey from #temp1) insert into originaldatabase.dbo.maintable select * from maintable where primarykey = the one deleted from the maintable this isn't a fully automatic restore solution but more of an accelerated disaster recovery solution i hope it helps,
it works fine for me
and, except for the triggers is "non-invasive" ie: i didn't have to rewrite 100 queries etc. All the best,
John Rivers
I checked out Log Explorer once
it was very slick but quite expensive
i feel for all the people who paid
for such software unnecessarily
as i almost did.
The author of the article you mentioned
also missed the fact that you can
backup a database after you mess it up
and still restore to a point in time before the backup.
Of course Lumigent will never admit that if you ring them - they
totally lied to me
on the phone - you would think a case of mushroom management of staff
(keep them in the dark and feed them sh*t) but i could hear they were
lying so
I researched further and solved my problem without it - great product
but don't
be tricked into buying it unnecessarily - knowledge is power :-)
For SQL Server I would suggest creating z-Tables. Anytime a record is
deleted (and I would also suggest for updated) just insert a record into
your backup table. If you doing eveything through stored procs you can do a
simple insert, if your doing direct table access I would suggest using
triggers to do the insert.
"Morgan Bachu" <ds********@tiscali.co.uk> wrote in
news:11**********************@g14g2000cwa.googlegr oups.com: Hello everybody,
I have an intranet application which is mostly a bunch of data editing forms.
The database has about 20 tables all related together.
Recently somebody deleted a "the wrong record" and the cascade delete in sql server did its work nicely :(
When they asked me to put the data back, I looked pretty stupid as I had no idea how.
How is this normally done in ASP.NET app?
Morgan
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dsfsdfs878 |
last post by:
Hello,
Somebody accidently deleted a record with cascade deletes
and took out about 80 records.
The database has been used heavily since then.
How do I put back the data?
I have spent...
|
by: ss.wisch |
last post by:
Ok here's the thing... I have a vBulletin forum database... there is a
table in there called "post" which has all of my forums posts in it.
What I have are many posts with regular titles like "Oh...
|
by: Paul |
last post by:
I have an Access 2000 database with a form that is giving me some
major headaches. When you open the form, it displays all records and
allows editing, but has AllowAdditions set to False so that...
|
by: babylon |
last post by:
any facilities in csharp that can help me implmenting undo/redo in my
application?
thx
|
by: Carpe Diem |
last post by:
Hello I have an aspx page that loses Session("user") value after a few
minutes even after I set
<sessionState mode="InProc" cookieless="false" timeout="300"> in web.config
and wrote
function...
| |
by: monkey3333sg |
last post by:
I would like to add an "undo" button in my programme
|
by: monkey3333sg |
last post by:
I am programming some flow chart program using VB6... which is similar to Visual Logic software... I would like to add in "Undo" and "Redo" part...anyone can help? Thank you.
|
by: PW |
last post by:
Hi,
I have a form with unbound fields on it. The user selects a record
from a recordset and I populate the unbound fields. When I try to
change the unbound quantity text box, Access 2003 tells...
|
by: Nilam2477 |
last post by:
I have a form with multiple TextBox controls and few other controls like comboBox, checkBox etc. I'm trying to implement Undo functionality for all the controls in the form. I'm using Push & Pop...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |