|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to validate fields on the form in C#I have a form with a number of fields, some of which would be
filled(populated) automatically from the MS SQL database on certain event.Now, I have certain validations on the fields from sql database as constraints(eg. format of the tel number), So I was wondering how do I catch these runtime exceptions which r likely to occur if the user enters something which violated the sql constraints. Also, on my form, the user can also change the information (which is populated by the sql database), this information after submitting goes back into the database which has constraints. So, I would like to validate this info b4 Sql throws exception. Any idea how to approach over this?? Controls that take user input will typically have a Validating event that
you can use to check the data the user entered. Show quoteHide quote "juventusaurabh" <saurabh.kot***@gmail.com> wrote in message news:1142018072.858520.320210@i39g2000cwa.googlegroups.com... >I have a form with a number of fields, some of which would be > filled(populated) automatically from the MS SQL database on certain > event.Now, I have certain validations on the fields from sql database > as constraints(eg. format of the tel number), So I was wondering how do > I catch these runtime exceptions which r likely to occur if the user > enters something which violated the sql constraints. > > Also, on my form, the user can also change the information (which is > populated by the sql database), this information after submitting goes > back into the database which has constraints. So, I would like to > validate this info b4 Sql throws exception. > > Any idea how to approach over this?? > You could use a validator control to check the values before they are
submitted to SQL. Technically, this checking should occur wherever your business logic rules exist (UI, Business Layer etc) so that once your business rules run against the input, you can throw an appropriate exception and display it to the user.
Other interesting topics
c# CP210x Wrapper InteropServices IntPtr HandleRef problem
Anonymous Methods As ThreadStarts Increase all digits in a number(string) one step Sockets, to be continued... C# Books Refering to Object Members in A Collection in an ASP.NET BoundColu finding the current user name accessing an ASP.NET page Embedding an image in a dll Using using verses specifying the namespace completely. Form Minimize |
|||||||||||||||||||||||