如何访问连接列的id并在C#中验证我们的winform [英] How to access the id of a concatenate column and validate our winform in C#

查看:69
本文介绍了如何访问连接列的id并在C#中验证我们的winform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们!

i有两个问题

优先:

i通过选择查询连接两列

this是查询

选择concat(Vehicle.Vehicle_Name,' - ',Vehicle.Vehicle_Model)作为[车辆名称]来自车辆

并分配给文本框1

现在我想访问textbox1.text的id



第二名:

有没有建成-in库中的c#来验证我们的winform

谢谢



我尝试了什么:



i试了很多但没找到漂亮的东西

hi guys!
i have two problems
first:
i concatenate two column through select query
this is the query
"select concat (Vehicle.Vehicle_Name, '-' , Vehicle.Vehicle_Model) as [Vehicle Name] from Vehicle"
and assign to a text-box1
now i want to access the id of the textbox1.text

Second:
is there any built-in library in c# to validate our winform
thanks

What I have tried:

i tried a lot but didn't find something beautiful

推荐答案

1)什么ID?文本字符串没有ID:它们只是:字符串。当你连接两个字符串时,你会破坏与数据库中任何特定行的关联。可能是您可以通过撤消串联和从数据库中选择返回来将字符串与行重新组合,但不能保证在所有情况下都能正常工作。在这个,它可能,但是 - 这是一个糟糕的主意。



更好的想法是创建一个包含行ID和两个字符串的类 - 然后覆盖ToString连接它们。从您的数据库中填写,并使用ComboBox而不是文本框让用户选择品牌和型号。这样,您可以使用所选项目来获取类实例,并且您可以使用rowID。



2)否。想一想:你有没有想知道我可能想在表格上做什么验证?那么为什么系统(或其他任何人)更想知道你想要什么样的验证呢?
1) What ID? Text strings do not have an ID: they are just that: strings. And when you concatenate two strings, you "break the association" with any particular row in the DB. It may be that you can "reunite" the string with the row by undoing the concatenation and SELECTing back from the DB, but it's not guaranteed to work in all cases. In this, it might, but - it's a poor idea.

A better idea is to create a class which contains the row ID, and the two strings - then override ToString to concatenate them. Fill that from your DB, and use a ComboBox instead of a text box to let the user pick the make and model. That way, you can use the selected item to get back the class instance and you have your rowID available.

2) No. Think about it: do you have any idea what validation I might want to do on my forms? So why would the system (or anyone else) have any more idea what validation you want?


这篇关于如何访问连接列的id并在C#中验证我们的winform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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