Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
pls help me for a problem

how to make a function
when i press a delete key on record in listview then
check its uniqe id in all other tabels of database
if found then give message record used in other table
and stop from delete

access database file
Posted
Updated 11-May-12 20:12pm
v2

You didn't mention the database you're using, but let's say it's SQL Server. Regardless of that, if you want to maintain the integrity of the data in the database, don't check the relations in your code. Use the features of the database instead. So if this is for example SQL Server, see SQL FOREIGN KEY Constraint[^]
 
Share this answer
 
Comments
P.Salini 12-May-12 2:16am    
My 5!
Wendelius 12-May-12 4:18am    
Thanks :)
Sandeep Mewara 12-May-12 5:56am    
5 again! :)
Wendelius 12-May-12 6:05am    
Thanks again ;)
Why you need function ? You can achieve this using stored procedure.

SQL
CREATE PROC SearchRecordInAllTableById
(
 @Id BIGINT
)
AS
BEGIN
  IF EXISTS (SELECT Id FROM TABLE1 WHERE ID=@Id)
   BEGIN
    RETURN 1
   END

  IF EXISTS (SELECT Id FROM TABLE1 WHERE ID=@Id)
   BEGIN
    RETURN 1
   END

RETURN 0
END
 
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