如何在C#中将datagridview复制回数据库 [英] How do I copy datagridview back to database in C#
本文介绍了如何在C#中将datagridview复制回数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个数据表来处理数据网格视图,但我真的无法理解
如何保存更改。请帮帮我
我的尝试:
object [] RowValues = {,,,,,,,,,,,,,, ,,};
RowValues [0] =;
RowValues [1] = noTextBox.Text;
RowValues [2] = textBox1.Text;
RowValues [3] = comboBox3.Text;
RowValues [4] = comboBox4.Text;
RowValues [5] = shiftTextBox.Text;
RowValues [6] = comboBox1.Text;
RowValues [7] = comboBox2.Text;
RowValues [8] = start_TimeDateTimePicker.Text;
RowValues [9] = end_TimeDateTimePicker.Text;
RowValues [10] =;
RowValues [11] = bagTextBox.Text;
RowValues [12] =;
RowValues [13] =;
RowValues [14] =;
RowValues [15] = remarkTextBox.Text;
DataRow dRow;
dRow = dtable.Rows.Add(RowValues);
pPMDataGridView.DataSource = dtable;
dtable = pPMDataSet.PPM;
解决方案
当您设置.DataSource
属性时,全部更改将自动保存。
请参见此处示例:如何在c#中从数据库填充datagridview - C-Sharp(C#)关于编码的讨论已解决 [ ^ ]
这里:DataGridView.DataSource属性(System.Windows.Forms) [< a href =https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource(v=vs.110).aspx\"target =_ blanktitle =New Window > ^ ]
I've created a datatable to work with datagrid view, but I really can't understand
how to save the changes. Please help me
What I have tried:
object[] RowValues = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; RowValues[0] = ""; RowValues[1] = noTextBox.Text; RowValues[2] = textBox1.Text; RowValues[3] = comboBox3.Text; RowValues[4] = comboBox4.Text; RowValues[5] = shiftTextBox.Text; RowValues[6] = comboBox1.Text; RowValues[7] = comboBox2.Text; RowValues[8] = start_TimeDateTimePicker.Text; RowValues[9] = end_TimeDateTimePicker.Text; RowValues[10] = ""; RowValues[11] = bagTextBox.Text; RowValues[12] = ""; RowValues[13] = ""; RowValues[14] = ""; RowValues[15] = remarkTextBox.Text; DataRow dRow; dRow = dtable.Rows.Add(RowValues); pPMDataGridView.DataSource = dtable; dtable = pPMDataSet.PPM;
解决方案
When you set the.DataSource
property, all changes will be saved automatically.
See example here: how to fill datagridview from database in c# - C-Sharp (C#) Discussions on Coding Resolved[^]
And here: DataGridView.DataSource Property (System.Windows.Forms)[^]
这篇关于如何在C#中将datagridview复制回数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文