Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 5: Validating Data > Database Validation

Database Validation

You can create your own validation rules at the database when working with an external SQL Server database. For example, you could create SQL Server check constraints to validate the data against a T-SQL expression. If a user attempts to enter data that conflicts with the database rules that you have defined, LightSwitch will return the error to the user in the validation result summary.

Earlier in this chapter, we showed you how to prevent users from entering duplicate records. If you were using an attached SQL Server database, you could apply this validation using a SQL Server unique constraint. To create a unique constraint, open your table in SQL Server Management Studio. On the toolbar, click the Index button, and the Indexes/Keys dialog box opens, as shown in Figure 5-8.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint