This example shows the use of the
EditErrorMessage property.
If you try to add the new record leaving the default value, you
will get a customized error message, because a category named "Beverages" already
exists in the table.
Analogously, if you try to update the CategoryName of an existing category, changing it to "Beverages",
you will get a customized error message, because a category named "Beverages" already
exists in the table.
Finally, if you try to delete an existing category, you are warned you cannot delete it, because
the category is not empty (that is, there are products in such category).
Add a new record
This is the code implementing the example:
<!--#include file="VBSdb/inc.asp"-->
<%
VbsDbNew objVbsDb
objVbsDb( "MdbPath" ) = "data/nwind.mdb"
objVbsDb( "Sql" ) = "select * from Categories"
objVbsDb( "ViewNavigationButtons" ) = "first;next;prev;last;search;add;update;delete"
objVbsDb( "GridHideFields" ) = "CategoryId;Picture"
objVbsDb( "FormHideFields" ) = "Picture"
objVbsDb( "EditTableName" ) = "Categories"
objVbsDb( "EditKeyFields" ) = "CategoryID"
objVbsDb( "EditErrorMessages" ) = "custom"
objVbsDb( "GlobalCustomText" ) = "addErrorMessage|This CategoryName already exists.;" & _
"updateErrorMessage|This CategoryName already exists.;" & _
"deleteErrorMessage|There are products in this Category."
objVbsDb( "EditHideFields" ) = "Picture"
objVbsDb( "EditAddFieldDefaults" ) = "CategoryName|Beverages"
objVbsDb( "GlobalStartScreen" ) = "Add"
VbsDb objVbsDb
%>
This demonstrative program connects to
Nwind.mdb, the well known Microsoft Access sample database: the names of companies,
products, people,
characters, and/or data mentioned herein are fictious and are in no way
intended to represent any real individual, company, product, or event.
To download a copy of Nwind.mdb, please visit
Microsoft's site.
|