June 17, 2004 at 2:50 pm
I am having problems consistently inserting my data into a table. On my form that contains two drop downs, an accout number is selected and a territory to transfer that account to is selected. However, when i submit the data, sometimes no record shows up and other times it will insert the record multiple times. Here is my stored procedure for inserting the account and its current territory, region, division and employee information. I'm guessing something is wrong here.
CREATE PROCEDURE InsertAccounts
@AccountID char(10),
@Explanation nvarchar(800)
AS
insert into accounttransfers
(AccountID, FromTerritoryID, FromRegionID, FromDivisionID, FromEmpID, Explanation)
select Accounts2.AccountID, Territories.TerritoryID, Regions.RegionID, Divisions.DivisionID, Employees.EmployeeID, @Explanation
From Accounts2, EndoscopySqlUser.Territories INNER JOIN
EndoscopySqlUser.Regions ON EndoscopySqlUser.Territories.RegionName = EndoscopySqlUser.Regions.Region INNER JOIN
EndoscopySqlUser.Employees ON EndoscopySqlUser.Territories.TerritoryID = EndoscopySqlUser.Employees.TerritoryID INNER JOIN
EndoscopySqlUser.Divisions ON EndoscopySqlUser.Regions.Division = EndoscopySqlUser.Divisions.DivisionID
Where (Accounts2.AccountID = @AccountID) and (Accounts2.TerritoryID = Territories.TerritoryID)
GO
June 18, 2004 at 3:14 am
Are you getting a consistent response for each territory? By this I mean when you select territory A you always get 4 new records added but territory B never adds any records. If so I would look at your Divisions/Regions/Territories tables to make sure all of the ID values are unique. If not then it suggests your form is firing off more than one call to your stored procedure.
Duncan
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply