DataGridView修改后直接保存到数据库实例程序

上传者: jsy2607219 | 上传时间: 2020-02-13 03:05:19 | 文件大小: 176KB | 文件类型: rar
C#中DataGridView修改后直接保存到数据库实例程序,绝对可用,内附源码,有注释 主要代码: //单元格编辑结束后触发 private void dataGridView1_CellEndEdit_1(object sender, DataGridViewCellEventArgs e) { try { string rowid = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); string cellhead = dataGridView1.Columns[e.ColumnIndex].DataPropertyName; string cellvalue = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); if (cellhead == "domain") { cellhead = "[domain]"; } else { } if (cellvalue == "True" && cellhead == "passed") { cellvalue = "1"; } else { if (cellhead == "passed") { cellvalue = "0"; } else { } } string sqlcmd = "update domain_info set " + cellhead + "='" + cellvalue + "' where id=" + rowid; if (dbo.DBcmd(sqlcmd)) { resultshow.Text = " 编辑成功"; } else { resultshow.Text = " 编辑失败"; } } catch { MessageBox.Show("异常", "错误"); } }

文件下载

资源详情

[{"title":"( 39 个子文件 176KB ) DataGridView修改后直接保存到数据库实例程序","children":[{"title":"WebSiteTest","children":[{"title":"WebSiteTest.csproj <span style='color:#111;'> 6.55KB </span>","children":null,"spread":false},{"title":"Form1.cs <span style='color:#111;'> 5.35KB </span>","children":null,"spread":false},{"title":"Program.cs <span style='color:#111;'> 491B </span>","children":null,"spread":false},{"title":"Database.sdf <span style='color:#111;'> 20.00KB </span>","children":null,"spread":false},{"title":"Form1.resx <span style='color:#111;'> 10.93KB </span>","children":null,"spread":false},{"title":"app.config <span style='color:#111;'> 619B </span>","children":null,"spread":false},{"title":"Properties","children":[{"title":"Settings.settings <span style='color:#111;'> 1.60KB </span>","children":null,"spread":false},{"title":"Resources.Designer.cs <span style='color:#111;'> 2.80KB </span>","children":null,"spread":false},{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.35KB </span>","children":null,"spread":false},{"title":"Settings.Designer.cs <span style='color:#111;'> 2.20KB </span>","children":null,"spread":false},{"title":"Resources.resx <span style='color:#111;'> 5.48KB </span>","children":null,"spread":false}],"spread":true},{"title":"domainDataSet.xsc <span style='color:#111;'> 3B </span>","children":null,"spread":false},{"title":"domain.mdb <span style='color:#111;'> 216.00KB </span>","children":null,"spread":false},{"title":"Form1.Designer.cs <span style='color:#111;'> 24.21KB </span>","children":null,"spread":false},{"title":"domainDataSet.xsd <span style='color:#111;'> 37.67KB </span>","children":null,"spread":false},{"title":"domainDataSet.Designer.cs <span style='color:#111;'> 146.53KB </span>","children":null,"spread":false},{"title":"DBOpera.cs <span style='color:#111;'> 1.13KB </span>","children":null,"spread":false},{"title":"obj","children":[{"title":"x86","children":[{"title":"Debug","children":[{"title":"WebSiteTest.exe <span style='color:#111;'> 71.00KB </span>","children":null,"spread":false},{"title":"GenerateResource.read.1.tlog <span style='color:#111;'> 270B </span>","children":null,"spread":false},{"title":"ResolveAssemblyReference.cache <span style='color:#111;'> 11.69KB </span>","children":null,"spread":false},{"title":"WebSiteTest.Properties.Resources.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"TempPE","children":[{"title":"domainDataSet.Designer.cs.dll <span style='color:#111;'> 52.00KB </span>","children":null,"spread":false},{"title":"Database1DataSet.Designer.cs.dll <span style='color:#111;'> 9.00KB </span>","children":null,"spread":false}],"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 6.55KB </span>","children":null,"spread":false},{"title":"WebSiteTest.pdb <span style='color:#111;'> 107.50KB </span>","children":null,"spread":false},{"title":"WebSiteTest.csproj.FileListAbsolute.txt <span style='color:#111;'> 791B </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferences.cache <span style='color:#111;'> 14.86KB </span>","children":null,"spread":false},{"title":"GenerateResource.write.1.tlog <span style='color:#111;'> 520B </span>","children":null,"spread":false},{"title":"WebSiteTest.Main.resources <span style='color:#111;'> 3.07KB </span>","children":null,"spread":false}],"spread":false}],"spread":false}],"spread":false},{"title":"domainDataSet.xss <span style='color:#111;'> 3B </span>","children":null,"spread":false},{"title":"bin","children":[{"title":"Debug","children":[{"title":"WebSiteTest.exe.config <span style='color:#111;'> 619B </span>","children":null,"spread":false},{"title":"WebSiteTest.exe <span style='color:#111;'> 71.00KB </span>","children":null,"spread":false},{"title":"Database.sdf <span style='color:#111;'> 20.00KB </span>","children":null,"spread":false},{"title":"WebSiteTest.vshost.exe.manifest <span style='color:#111;'> 490B </span>","children":null,"spread":false},{"title":"WebSiteTest.vshost.exe.config <span style='color:#111;'> 619B </span>","children":null,"spread":false},{"title":"WebSiteTest.vshost.exe <span style='color:#111;'> 11.33KB </span>","children":null,"spread":false},{"title":"domain.mdb <span style='color:#111;'> 216.00KB </span>","children":null,"spread":false},{"title":"WebSiteTest.pdb <span style='color:#111;'> 107.50KB </span>","children":null,"spread":false}],"spread":false},{"title":"Release","children":null,"spread":false}],"spread":false},{"title":"WebSiteTest.csproj.user <span style='color:#111;'> 451B </span>","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

  • nettt :
    感谢分享,很好的学习资料
    2020-05-08
  • hao08 :
    可以用,有参考价值
    2020-02-13
  • @kolalo :
    不错,很值得借鉴
    2019-10-26
  • weixin_44588034 :
    非常的实用
    2019-06-22
  • lonsondong :
    不錯,可以用於学习参考,谢谢
    2018-11-07

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明