简体   繁体   中英

How to save data from a DataGridView into database? c# winforms

I have this little application, and what it does is a user can add many deductions to a certain employee and save the record.

替代文字

What I do in my coding is I pass all the values to a DataTable and loop through each rows and execute a stored procedure that inserts the particular row with the column values. This happens until there are no rows to be inserted from the DataTable.

Is there any shortcut? I mean, can I insert the whole value of datatable in one call? I just thought that my current way of inserting data is very resource consuming because it always calls the stored procedure in the server as long as there are rows in the datatable.

Any work around or suggestions? I would be very thankful. I hope you understand me,. thanks in advance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM