将数据从datagridview插入到访问表中 [英] Insert data from datagridview into access table

查看:58
本文介绍了将数据从datagridview插入到访问表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个datagridview,只需点击一下按钮即可手动添加行...我继承了一个类的列,使其成为单元格datatimepicker.i需要将其插入数据库,而无需先从数据库



我尝试过:



插入行by row by command excutenonquery

解决方案

如果我正确理解了这个问题,你可以

- 而不是从数据库中填充数据表,定义具有与datagridview(和您的实际表)匹配的所需结构的数据表

- 将数据表绑定到datagridview

- 对数据表进行修改(由用户进行)

- 使用OleDbDataAdapter来反映从数据表到Access数据库的变化。



看看下面的文章:如何:B ind数据到Windows窗体DataGridView控件 [ ^ ]它使用Sql Server类,如SqlCommand或SqlConnection,但您可能会使用OleDbCommand和OleDbConnection等。否则这应该让你开始。


从这里开始:访问批量记录插入 [ ^ ]

I have this datagridview whose rows are manually added on a click of a button..and i inherit a class to it's column to make it's cell datatimepicker.i need to insert it into the database without the need to retrieve it first from the database

What I have tried:

to insert it row by row by command excutenonquery

解决方案

If I understand the question correctly, you could
- Instead of populating a datatable from the database, define a data table having the desired structure that matches your datagridview (and your actual table)
- bind the datatable to the datagridview
- make modifications to the datatable (by the user)
- use OleDbDataAdapter to reflect the changes from the datatable to the Access database.

Have a look at following article: How to: Bind Data to the Windows Forms DataGridView Control[^] It uses Sql Server classes such as SqlCommand or SqlConnection but you would probably use OleDbCommand and OleDbConnection etc instead. Otherwise this should get you started.


Start here: Bulk Record Insert for Access[^]


这篇关于将数据从datagridview插入到访问表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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