从网格视图批量复制到SQL表。 [英] Bulk copy to SQL table from grid view.

查看:120
本文介绍了从网格视图批量复制到SQL表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



实际上我有一个Gridview,我在网格中有一些值。我的网格视图有超过30列(也是行),它包含特定月份的日期。



所以我在我的SQL中创建了一个相同的表我在网格视图中的列名。



现在我想从网格视图中将所有记录复制到数据表(SQL)中。





Gridview1 ------> tbl。[date_register]。



我尝试了什么:



我已经尝试使用for循环和插入查询。但我仍然需要在查询中输入我的所有31列。那么有没有办法大规模上传或批量上传值从网格视图到SQL表?



我的意思是没有使用for循环和插入查询?

请帮助我...

Hi All,

Actually i have one Gridview and i have certain values in the grid. My grid view is having more than 30 columns(rows also) that is it contains dates of particular month.

So i have created one table in my SQL with the same column name as i had in my Grid view.

Now i want to copy all my records into the data table(SQL) from grid view.


Gridview1------>tbl.[date_register].

What I have tried:

I have tried it using the for loops and insert query. But still i have to enter all my 31 columns in the query. SO is there any way to mass upload or bulk upload the values from grid view to SQL table?

I meant any way without using for loops and insert query?
pls help me...

推荐答案

这实际上取决于您使用哪些数据作为网格视图的数据源。



SqlBulkCopy方法(System.Data.SqlClient) [ ^ ]



如果其中一种数据类型被<$接受c $ c> WriteToServer 您已设置的方法。否则,如果它是一些集合,你可以使用LINQ 选择转换为其中一种类型。



如果没有关于数据源的更多信息,我就不能更具体了。
It really depends on what data you are using as a data source for your grid view.

SqlBulkCopy Methods (System.Data.SqlClient)[^]

If its one of the data types accepted by the WriteToServer methods you are all set. Otherwise, if its some collection, you can probably use a LINQ Select to convert to one of those types.

Without more information about your data source, I cannot be more specific.


这篇关于从网格视图批量复制到SQL表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆