Import Data from Excel and CSV to SQL server using C# in Asp.net

Import Data from Excel and CSV to SQL server using C# in Asp.net

The Page having a FileUpload control and the Upload button, on selecting the Excel or CSV file user needs to click on Upload button to store the data to Server. Here we are treating the uploaded file as database hence we need to create OLEDB connection to this file, from this connection will be created and the data is fetched to C# as DataTable. '[Sheet1$]' is the Name of the Worksheet where requires data is present. Table CREATE TABLE [dbo].[Tag]( [ID] [int] IDENTITY(1,1) NOT NULL, [TagType] [int] NULL, [TagCode] [nvarchar](100) NULL, [Status] [bit] NULL, [Duration] [int] NULL) Stored Procedure Create proc [dbo].[ExcelTag] @TagType int, @TagCode nvarchar(100), @Status bit, @Duration int as if Not exists(Select top 1 TagCode from dbo.[Tag] where TagCode=@TagCode) Begin insert into dbo.[Tag](TagType,TagCode,[Status],Duration)values(@TagType,@TagCode,@Status,@Duration) End