Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to save a list data into sqlserver database.....

I want to save multiple row at one time from Aspx page to sqlserver.
Posted
Comments
Thanks7872 11-Nov-13 7:01am    
Where is the code you have implemented till now?
Parmendra choudhary 11-Nov-13 7:07am    
I just want to save Patient's treatment information so multiple medicine save at one time.
Thanks7872 11-Nov-13 7:25am    
Ok but where is the code and what problem did you face with that code?

Go through the Article to know Multiple Ways to do Multiple Inserts[^].

The easiest way is to create one XML string and send that to the Stored Procedure and inside the Procedure, read the values and insert to table.

See one example- Inserting multiple rows in single command using asp.net[^].
 
Share this answer
 
Comments
Parmendra choudhary 11-Nov-13 7:15am    
I just want to save data with listview
Okay, so loop through the record and make one XML and send that to Database. You can't directly insert.
thatraja 11-Nov-13 7:27am    
5! for the 1st link
Thanks a lot... :)
You should pass your records as table as "sqldbType.structured". and in database procedure handle the table.

in database create a type:

SQL
CREATE TYPE LogData AS TABLE(
 [Date] [varchar](20) NULL,
 [Scbytes] [bigint] NULL,
 [CsHost] [varchar](256) NULL
)


then use that type in procedure


SQL
[prc_insertlog]
       @intClientID INT ,
      @tlbLogData  LogData READONLY


In aspx page just create a datatable with the fields as in Type. and pass in the procedure.

In sql server, you should create cursor. OPen cursor and fetch the rows one by one. and loop until @@FETCH_STATUS = 0.

Hope your problem will be sorted out :)
 
Share this answer
 
Comments
veer kushwaha 6-Jan-14 1:08am    
The Code for Honor contest by Microsoft is a fabulous opportunity for talented developers in India to showcase their flair for developing unique apps. I wish all my buddies who want to participate, good luck! Click on the link to know more and participate http://bit.ly/19nbuG0

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