Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends
i have three table and i want to delete record from three table by signal query
i have try this but getting error ?
can any buddy help me what i have to do?????????

C#
cmd .CommandText =("DELETE FROM (ITEMMAST x INNER JOIN SAUDAMAST y)INNER JOIN PITBROK Z  ON x.ITEMCODE = y.ITEMCODE=Z.ITEMCODE WHERE ITEMCODE='" + textBox1.Text + "'");
cmd.ExecuteNonQuery();
MessageBox.Show("RECORD DELETED", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
Posted
Updated 14-Dec-11 20:38pm
v3
Comments
uspatel 15-Dec-11 2:35am    
EDIT: 'pre' tag added.
koolprasad2003 15-Dec-11 2:39am    
Change letterCase to 'small', do not use capital letters. it means "Shouting".

 
Share this answer
 
Hi,

You could define Foreign Key constraints for the other tables that reference
the master table's primary key with ON DELETE CASCADE. This would cause the
related rows in those tables to be deleted. See the discussion thread below,
http://forums.whirlpool.net.au/archive/560152[^]
 
Share this answer
 
you can do this by stored procedure as
SQL
CREATE PROCEDURE proc_delete_item
@ItemCode int,

AS
SET NOCOUNT off
DECLARE  @LocalError int

BEGIN TRANSACTION

DELETE FROM ITEMMAST where ItemCode=@ItemCode
DELETE FROM SAUDAMAST where ItemCode=@ItemCode
DELETE FROM PITBROK where ItemCode=@ItemCode

SELECT @LocalError = @@Error
IF NOT @LocalError = 0
    BEGIN
    ROLLBACK TRANSACTION
    SELECT  Error = @LocalError
        
    END
ELSE
    BEGIN
    COMMIT TRAN
   
    SELECT  Error = 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