开发者

Can ADO.NET create its own basic validation by reflecting the database structure?

开发者 https://www.devze.com 2022-12-08 02:39 出处:网络
I am now to the stage of adding validation to a simple app for editing a few SQL tables via data-bound controls. I can see that the BindingSource knows the limits of the table\'s structure: if I enter

I am now to the stage of adding validation to a simple app for editing a few SQL tables via data-bound controls. I can see that the BindingSource knows the limits of the table's structure: if I enter, for example, letters in a field that should contain only decimals, up pops a DataError exception with the message that you can only enter decimals there.

It seems to me that ADO.NET should be able to use reflection to generate basic validation for all the data-bound fields. But after a lot of Googling, I see only people creating their own validation by column by column.

Can I use ADO.NET's knowledge of the database structure to have it make some of the开发者_如何学Go basic validation for me (e.g. data type, text field length limits)? Do you have some examples?


I'm sad that I've never gotten a good response on this question... but I think I have my answer:

Yes, it should be possible, but no, it hasn't been done yet.

(Maybe someday I'll start a project myself to make a tool which would auto-generate basic validation values for data-bound form fields.)

0

精彩评论

暂无评论...
验证码 换一张
取 消