使用Sql数据库和C#创建Window应用程序 [英] Creating Window application by using Sql database and C#

查看:109
本文介绍了使用Sql数据库和C#创建Window应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当另一个表中存在当前单元格值时,我想用另一个表的值来验证datagridview的当前单元格,然后我允许他编辑

I want to validate the current cell of datagridview with the value of another table when the current cell value persent in another table then i allow him to edit

推荐答案

进行数据库调用以检查每次单元格编辑中的值都不是一个好方法.我建议也获取查找数据并将其保存在对象中.然后,您可以使用之前获取的值在CellValidating或适用的事件中检查当前单元格的值.

如果有人在获取数据后继续在网格中进行编辑,那么这种方法将在一定程度上带来问题.
Doing a database call to check for the values on every cell edit will not be a good way. I would suggest to get the look up data as well and save it in an object. You can then check the current cell value on the CellValidating or as applicable event with the values you have retrieved earlier.

This approach will offcourse have a problem if someone updates the look up table between the time you get the data and go on to edit in grid.


这篇关于使用Sql数据库和C#创建Window应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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