insert into datbase using stored procedure and .net code by standard form control
In this blog we are going to show that how you will store the data inside a data base from a simple form using the store procedure
Database coding
<>SQL SERVER CREATE PROCEDURE WITH OUTPUT PARAMETER>Use the below code to use a particular database
// USE name_of_the_database USE DB02TEST01
Create a table to insert data using the precedure
CREATE TABLE EtaxiSystem_1937935( BookingReferenceNumber INT PRIMARY KEY IDENTITY(100000,1), PassengerName VARCHAR(50), FromLocation VARCHAR(50), ToLocation VARCHAR(50), DepartureTime DATETIME, DistanceinKm INT, EstimatedAmount INT, CabType VARCHAR(50) )
Use the below code to see the table data It is present
select * from EtaxiSystem_1937935
Execute the below code to create a procedure in sql server
Below is the code for stored procedure
CREATE PROCEDURE ETaxiProcedure ( @PassengerName VARCHAR(50), @FromLocation VARCHAR(50), @ToLocation VARCHAR(50), @DepartureTime DATETIME, @DistanceinKm INT, @EstimatedAmount INT, @CabType VARCHAR(50), @BookingReferenceNumber INT OUT ) AS BEGIN INSERT INTO EtaxiSystem_1937935 VALUES ( @PassengerName, @FromLocation, @ToLocation, @DepartureTime, @DistanceinKm, @EstimatedAmount, @CabType) SET @BookingReferenceNumber = @@IDENTITY END
Execute the code to see your procedure is working or not
You can use the below code for checking your stored procedure
DECLARE @BookingReferenceNumber1 INT EXEC ETaxiProcedure 'Rumman', 'Kolkata', 'Kerala', '12.02.1996', 1, 10, 'indigo', @BookingReferenceNumber1 OUT PRINT @BookingReferenceNumber1
Now see the table details using the below code again
SELECT * FROM EtaxiSystem_1937935