c# - 通过datagridview中的选定行使用第二种形式更改数据库表
问题描述
我的第一个表单中有一个 DataGridView,我制作了第二个表单来使用以下代码创建一个数据库条目:
clsMSSQL.clsMSSQL ticket = new clsMSSQL.clsMSSQL(5);
string query = "INSERT INTO ticket.support (Betreff, Problembeschreibung, Kategorie, Ersteller, Bearbeiter, E-Mail, Abteilung) " +
"Values('" + textBox1.Text + "', '" + textBox2.Text + "', '" + comboBox1.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "', '" + textBox8.Text + "', '" + comboBox3.Text + "')";
ticket.Query(query);
ticket.Close();
myDGW.Refresh();
this.Close();
现在我制作了第三种形式,它应该能够从第一种形式中获取选定的行并使用文本框更改值。
我试过这个:
clsMSSQL.clsMSSQL ticket = new clsMSSQL.clsMSSQL(5);
string query = "UPDATE ticket.support SET = (Betreff, Problembeschreibung, Kategorie, Ersteller, Bearbeiter, E-Mail, Abteilung) " +
"Values('" + textBox1.Text + "', '" + textBox2.Text + "', '" + comboBox1.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "', '" + textBox8.Text + "', '" + comboBox3.Text + "') WHERE id='" + dataGridView1.Rows[i].Cells[11].Value.ToString() + "'";
ticket.Query(query);
ticket.Close();
myDGW.Refresh();
this.Close();
但它不起作用。
解决方案
推荐阅读
- marklogic - MarkLogic 升级 - 维护版本还是版本升级?
- python - TypeError:字符串格式化期间并非所有参数都转换(Python Typeerror)
- flutter - 如果 Flutter 中的 Textfield 为空,如何显示 AllertDialog
- python - 在 Jupyter Notebook 中使用 argparse 运行 python 程序来设置输入
- google-sheets - 给定一个值,你能返回一系列忽略空白但包括重复的行吗?
- spring - 如何将自定义过滤器应用于特定网址?
- wso2 - API 网关未与反向代理 WSO2 连接
- spyder - Linting 不再显示在 Spyder 的侧边栏上?
- json - 出现错误:无法在 React 中使用 Fetch 读取未定义的属性“地图”?
- logistic-regression - 如何在 Weka 中修改逻辑回归模型的系数?