Click here to Skip to main content
15,878,970 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can we store thousand record in data base in one click in asp.net code
Posted

Yes, you would just have to write SQL to do it. Or, you could write a loop in C# to do it. Either way.
 
Share this answer
 
there is option sqlbulkcopy to store huge data in db (sql server db)
 
Share this answer
 
you can use xml procedure to do that
 
Share this answer
 
ASP.Net is nothing but a medium that stores data in a SQL table in this case particularly. If you can store those records in a SQL query in the SQL Server then you can definitely do the same successfully in ASP.Net.
 
Share this answer
 
For this first you have to create temporary Datatable
and store this datatable in gridview
and then click on final submit button in this you have to create insert query with the help of xml
i have paste my query go through it
USE [BU_WEB_AFFIL]
GO
/****** Object: StoredProcedure [dbo].[Proc_Profile_insertCommitteeDetails] Script Date: 10/05/2013 17:37:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author: Chitransh
-- Create date: 27/9/2013
-- Description: details of Commitee management Details
--Page NAme: frmCommitteeDetails.aspx
-- =============================================
ALTER PROCEDURE [dbo].[Proc_Profile_insertCommitteeDetails]
(
@collegeCode varchar(10),
@xmlData xml
)
AS
BEGIN
Begin Try
Begin Transaction t
delete from T_Profile_CommitteeDetails where collegeCode=@collegeCode
insert into T_Profile_CommitteeDetails(formationDate,validtill,memberName,designation,contactNo,collegeCode)
select Doc.col.value('formationDate[1]','datetime') as formationDate
,Doc.col.value('validTill[1]','datetime') as validTill
,Doc.col.value('memberName[1]','varchar(100)') as memberName
,Doc.col.value('designation[1]','varchar(50)') as designation
,Doc.col.value('contactNo[1]','varchar(15)') as contactNo
,@collegeCode
from @xmlData.nodes('Committee/table') as doc(col)
COMMIT TRANSACTION t
End TRY
BEGIN CATCH
ROLLBACK TRANSACTION t
DECLARE @erromsg NVARCHAR(4000)
DECLARE @errseverity INT
DECLARE @errstate INT
SELECT @erromsg = ERROR_MESSAGE(), @errseverity = ERROR_SEVERITY(), @errstate = ERROR_STATE()
RAISERROR(@erromsg, @errseverity, @errstate)
END CATCH
End
 
Share this answer
 
You can use sqlBulCopy class to insert multiple records into database.

Please refer the below link.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900