bonjour,

Apres l'execution de la stored procedure, les deux tables Address, ContactInformation sont rempli mais la table EndUser est vide, pouvez vous me dire pq ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
 
ALTER PROCEDURE [dbo].[EndUser_Insert]
 
@FirstName          nvarchar(50),
@LastName          nvarchar(50),
@AddressLine          nvarchar(50),
@AddressLine2    nvarchar(50),
@City                    nvarchar(50),
@State                  nvarchar(50),
@PostalCode        nvarchar(50),
@Phone                nvarchar(50),
@Phone2              nvarchar(50),
@Fax                    nvarchar(50),
@Email                 nvarchar(50),
@EndUserTypeID int,
@Password           nvarchar(50),
@IsSubscribed      bit
 
AS
 
--Start the transaction
BEGIN TRANSACTION
 
DECLARE @AddressID int
DECLARE @ContactInformationID int
 
INSERT INTO Address
(AddressLine,
AddressLine2,
City,State,
PostalCode)
VALUES
(@AddressLine,
@AddressLine2,
@City,
@State,
@PostalCode)
SET @AddressID = @@IDENTITY
 
-- Roll back the transaction if there are any errors
 
IF @@ERROR <> 0
BEGIN
-- Roll back the transaction
ROLLBACK
 
-- Raise an error and return
RAISERROR ('Error INSERT INTO Address.', 16, 1)
RETURN
END
 
INSERT INTO ContactInformation
(Phone,
Phone2,
Fax,
Email)
VALUES
(@Phone,
@Phone2,
@Fax,
@Email)
SET @ContactInformationID = @@IDENTITY
 
-- Roll back the transaction if there are any errors
 
IF @@ERROR <> 0
BEGIN
-- Roll back the transaction
ROLLBACK
-- Raise an error and return
 
RAISERROR ('Error INSERT INTO ContactInformation', 16, 1)
RETURN
END
 
INSERT INTO EndUser
(EndUserTypeID,
FirstName,
LastName,
AddressID,
ContactInformationID,
Password,
IsSubscribed)
VALUES
(@EndUserTypeID,
@FirstName,
@LastName,
@AddressID,
@ContactInformationID,
@Password,
@IsSubscribed)
 
SELECT @@IDENTITY
-- Roll back the transaction if there are any errors
IF @@ERROR <> 0
BEGIN
-- Roll back the transaction
ROLLBACK
-- Raise an error and return
RAISERROR ('Error INSERT INTO EndUser', 16, 1)
RETURN
END
COMMIT