Ans
Posts: 53
|
Posted: 05/29/2006, 10:41 PM |
|
Running jsp on MS SQL Server 2000. I place this code under the server event 'OnValidate'.
I have a table 'owner' with a pri key(deptID(int), modelID(int), para(char)).
Quote :
if (! e.getRecord().isEditMode() ||
! e.getPage().getHttpPostParameter("para", "").equals(e.getPage().getHttpGetParameter("para", "")) ||
! e.getPage().getHttpPostParameter("deptID", "0").equals(e.getPage().getHttpGetParameter("deptID", "0")) ||
! e.getPage().getHttpPostParameter("modelID", "0").equals(e.getPage().getHttpGetParameter("modelID", "0"))
) {
Object isUniqueValue = DBTools.dLookUp("deptID", "owner",
"para="+DBTools.toSql(e.getPage().getHttpGetParameter("para", ""),
JDBCConnection.TEXT,"testDB")+
" AND deptID="+DBTools.toSql(e.getPage().getHttpGetParameter("deptID", "0"),
JDBCConnection.INTEGER,"trestDB")+
" AND modelID="+DBTools.toSql(e.getPage().getHttpGetParameter("modelID", "0"),
JDBCConnection.INTEGER,"testDB"), "testDB");
if (isUniqueValue!=null) {
e.getRecord().addError("Combination already exits.");
}
}
I am trying to insert a check for a multiple primary key. I followed the example in CC, but it does not show my custom error msg but the complicated database error msg.
Is there anything wrong with my codes? Or do I have to activate other settings?
|
|
|
mrachow
Posts: 509
|
Posted: 05/29/2006, 11:58 PM |
|
I would suggest to first try your dLookUp w/o the if in front of it
_________________
Best regards,
Michael |
|
|
Nico
|
Posted: 06/28/2006, 1:27 AM |
|
Quote :,"trestDB"
>> First, I think you should write "testDB" instead of "trestDB"
|
|
|
|