如何将datagridview项(包括列和行)插入数据库 [英] How do I insert datagridview items(both columns and rows) to a database

查看:239
本文介绍了如何将datagridview项(包括列和行)插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我如何将datagridview项目插入数据库???

Can anyone please show me how to insert datagridview items to database???

推荐答案

首先你不应该害怕使用谷歌或任何其他搜索引擎。你可能真的找到了很好的解决方案,只需用你的问题作为搜索短语



如何插入datagridview数据进入c#数据库[ ^ ]



也就是说,通常最好使用DataSet或DataTable作为DataGridView的数据源,然后从DataSet更新数据库。

参见如何:将数据绑定到Windows窗体DataGridView控件 [ ^ ]



DataAdapter类 [ ^ ]用于将数据从数据库中获取到数据集(SELECT)并添加新行(INSERT)或更新数据库中的现有行(UPDATE)。



MSDN上有关于这个主题的相当不错的文章

如何:将数据集更改保存到数据库 [ ^ ]
First of all you shouldn't be afraid to use Google or any other search engine. You might actually find pretty good solutions just using your question as the search phrase

how to insert datagridview data into database in c#[^]

That said, it is usually better to use a DataSet or a DataTable as the data source of the DataGridView and then update the database from the DataSet.
See How to: Bind Data to the Windows Forms DataGridView Control[^]

The DataAdapter class[^] is kind of made for both getting data from the database into the data set (SELECT) and to add new rows (INSERT) or update existing rows (UPDATE) in the database.

MSDN has pretty good articles on the subject
How to: Save Dataset Changes to a Database[^]


这篇关于如何将datagridview项(包括列和行)插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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