我可以使用哪个vb代码将数据从dataGridView复制到sql server表中? [英] which vb code can I use to copy data from a dataGridView to pasted in a sql server table?

查看:105
本文介绍了我可以使用哪个vb代码将数据从dataGridView复制到sql server表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,在那个表单中我有datagridview。我有一个按钮(浏览),它从excel表中获取数据并粘贴到datagridview中。现在我正在尝试从datagridview复制数据并粘贴到sql server表中。

I have a form and in that form I have the datagridview. I have a button (browse) which get the data from an excel table and pasted into the datagridview. Now I'm trying to copy the data from datagridview and pasted into a sql server table.

请帮助!!




推荐答案

您好,

最好的建议是将Excel加载到DataTable中DataColumn的名称与SQL-Server表中的字段名称相同,然后使用
SqlBulkCopy的。如果DataColumn名称不同,则需要在设置SqlBulkCopy类实例时映射字段。

Best advice is to load Excel into a DataTable with DataColumn names the same as the field names in the SQL-Server table then use SqlBulkCopy. If DataColumn names differ you will need to map fields when setting up the SqlBulkCopy class instance.

或从Excel到SQL-Server


这篇关于我可以使用哪个vb代码将数据从dataGridView复制到sql server表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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