Click here to Skip to main content
11,704,768 members (50,027 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
i have table: 1)user
fields:name,
address,
mob,
log_id

2)login
fields:log_id
username,
password

when i update or delete record from user table ,update or delete record from login table also done.
i have to use store procedure for that.I don't know how to update,delete records using store procedure in multiple table.
Posted 20-Jan-13 3:16am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can turn on Cascade Delete [^] which will allow you to allow you to delete foreign key rows.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,

It would help if we knew what fields you have available on update or delete, but here I will assume you have al the fields in the user table.

For Update

Create Procedure ProcUpdateUser()
@logid int,
@name varchar(50)
 
as 
begin
update user set name=@name where log_id=@logid
update login set username=@name where log_id=@logid
 
end

For Delete

Create Procedure ProcDeleteUser
 
@name varchar(50)
 
as
begin
delete user where name=@name
delete login where username=@name
 
end


You will need to change the parameters according to your needs but hope this helps.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 679
1 OriginalGriff 455
2 Andy Lanng 245
3 CPallini 242
4 Maciej Los 225
0 OriginalGriff 8,864
1 Sergey Alexandrovich Kryukov 8,245
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100