MSI Factory 2.3

MSI.ViewGetError

MSI.ViewGetError

This is the first topic This is the last topic  

MSI.ViewGetError

This is the first topic This is the last topic  

OverviewExamples

table MSI.ViewGetError (

number hView )

Example 1

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