MSI.ViewGetError |
|
|
|
MSI.ViewGetError |
|
|
|
|
||
OverviewExamples
hDatabase = MSI.GetActiveDatabase(_hInstall);
if (hDatabase ~= 0) then
-- Get the Control table
strQuery = "SELECT * FROM `Control`";
hView = MSI.DatabaseOpenView(hDatabase, strQuery);
if (hView ~= 0) then
bExecuteResult = MSI.ViewExecute(hView, 0);
if (bExecuteResult) then
-- Get the first control
hRecord = MSI.ViewFetch(hView);
if (hRecord ~= 0) then
-- Try to set the Y value to a negative number
-- This is invalid, and will cause a validation error
MSI.RecordSetInteger(hRecord, 5, -10);
-- Validate the record
bSuccess = MSI.ViewModify(hView, MSIMODIFY_VALIDATE, hRecord);
if (not bSuccess) then
strMsg = "Error validating record"
-- Get the view validation error
tbError = MSI.ViewGetError(hView);
if (tbError ~= nil) then
strMsg = strMsg..":\r\nColumn: "..tbError["ColumnName"].."\r\nError Code: "..tbError["ErrorCode"];
end
-- Display the error message
Dialog.Message("Error", strMsg);
end
else
Dialog.Message("Error", "View Fetch Failed");
end
MSI.CloseHandle(hRecord);
else
Dialog.Message("Execute Failed", "Execute Failed.");
end
MSI.ViewClose(hView);
MSI.CloseHandle(hView);
else
Dialog.Message("View Error","View Failed.");
end
MSI.CloseHandle(hDatabase);
end
This example illustrates the functionality of the MSI.ViewGetError action by setting a record field to invalid data causing a validation error.
See also: Related Actions
Learn More: Indigo Rose Software - MSI Factory - Buy Now - Contact Us