Click here to Skip to main content
15,907,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HIe!

I am creating a windows application in vb.net
databse : MS Access

can any one tell me how to delete record logically rather than Physically ?

i have no idea how to do please give ma some sample code ....


Thank you
Posted
Comments
DaveAuld 2-Jul-10 6:40am    
What you on about, logically or physically.............
CPallini 2-Jul-10 6:51am    
Uh? What do you mean? Cannot you use a field as flag to exclude ('logically delete') unwanted records?

Do you mean to mark it as deleted rather than to actually remove it from the database?

If so I usually add a column named IsActive as a bit field (boolean in Access) and default it to 1 or true.

When I want to 'hide' (delete) the record I update the row to reflect that IsActive is now 0 (zero) or false.

Whenever you query the data ensure that the where clause contains

and IsActive = 1

or
and IsActive = 0


as appropriate.

Course, you probably meant something else entirely...
 
Share this answer
 
Comments
Npanchasara 6-Jul-10 1:04am    
Can you tell me with example i didnt uinderstand as much ....PLease
implement :
Imports System.Data
Imports System.Data.OleDb


then use this procedure
Sub AccessDeleteRow()
Dim connStr As String = "Data Source=mdbFileLocate;Provider=Microsoft.Jet.Oledb.4.0;connection Timeout=15"
Dim oleConn As New OleDbConnection(connStr)
oleConn.Open()
Dim cmd As New OleDbCommand("Delete from TableName where ColoumnName=Condition", oleConn)
cmd.ExecuteNonQuery()
oleConn.Close()
End Sub

mdbFileLocate Such as c:\db.mdb
delete sql command such as delete from employees where employeeid=4
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900