Create a random number and Insert it into a DB field
How to create a random number and insert it into a database field along with information fom you web form.
CREATE PROCEDURE spProcedureName
-- The values from the web form
@Textfield1 varchar(20),
@Textfield2 varchar(20)
AS
-- Create the variables for the random number generation
DECLARE @Random int;
DECLARE @Upper int;
DECLARE @Lower int
-- This will create a random number between 1 and 999
SET @Lower = 1 -- The lowest random number
SET @Upper = 999 -- The highest random number
SELECT @Random = Round(((@Upper - @Lower -1) * Rand() + @Lower), 0)
SET NOCOUNT ON
INSERT INTO tblTableName(dbColumn1, dbColumn2, ColumnForRandomNumber)
VALUES (@Textfield1, @Textfield2, @Random)
SET NOCOUNT OFF
GO
In the example above, we used a web form with two textfields (Textfield1, Textfield2) that would be inserted into a database table named "tblTableName". The random number would be generated by the Stored Procedure and inserted into the third column named "ColumnForRandomNumber". Be sure to change the names of these fields and columns to reflect your own form and database.
After creating this stored procedure in SQL server you can call it by using the DMX/UD Recordset or Command server behavior. In the server behavior dialog box you may be asked to fill in the default values, run-time value and/or other values for the web form textfields.
Comments
please comlete the entire tutorial
I wish you could finish it on how to add this funcationalty with DWMX
You must me logged in to write a comment.