hi all,
i have create a form(web app) to register customer details with "Submit" button.Once i click button "New" the registration form
will appear with new generated Account Number.after fill form click submit to save into SQL server database..
While one customer register his details another customer from other place Click button "New" to make registration.
so same Account Number will generated and build problem when both click "Submit" button at same time.
how could i prevent this problem ?
if i use locking method to lock Account Number when click "New". Is this possible?
Loading
Manikavelu VelayuthamPosted Sep 2, 2010, 3:08 AM
In another way, while checking in the table that the number already exists, just store the next number while storing.
Dont forget to mark this post as answered.
jeeva sanPosted Sep 2, 2010, 3:03 AM
there is any chance to solve this problem without modify the database?
(if i create the same Account ID when click "Submit" button.Hw can make it?)
Manikavelu VelayuthamPosted Sep 2, 2010, 2:56 AM
jeeva sanPosted Sep 2, 2010, 2:53 AM
where to use this codes?
can you explain more
(.Once i click button "New" the registration form
will appear with new generated Account Number.after fill form click submit to save into SQL server database)
when i click "NEW" button the data will generated in form only and not saved into database
Manikavelu VelayuthamPosted Sep 2, 2010, 2:41 AM
CREATE FUNCTION udf_UniqueNumber(
@UniqueID INT,
@ID INT
)
RETURNS VARCHAR(10)
AS
BEGIN
DECLARE @Name VARCHAR(100) = (SELECT [Name]
FROM Names
WHERE ID = @UniqueID )
DECLARE @RET VARCHAR(10) = CAST(@ID AS VARCHAR(10))
DECLARE @LEN INT = LEN(@RET)
SET @RET = UPPER(LEFT(@Name,3)) +
STUFF(@RET,1,0,LEFT('0000000',7 - @LEN))
RETURN @RET
END
CREATE TABLE Names(
ID INT Identity(1,1) NOT NULL PRIMARY KEY,
NameID INT NOT NULL FOREIGN KEY REFERENCES Person(ID),
UniqueId AS dbo.udf_SET_JobCode(PersonID, ID), -- Unique Number Generation
Comments VARCHAR(200) NOT NULL
)
Just insert the values in the table Names. UniqueId will be automatically generated.
You can remodify the user defined function as per your Unique Id generation
Dont forget to mark this post as answered.