Sreejith K
Sreejith K

Reputation: 53

Disable fox pro table trigger from c# (.NET)

I need to add a row to a fox pro table and before inserting the row I need to disable the trigger applied on the fox pro table and enable it back after inserting the row.

Is there any way to disable fox pro trigger from c# .NET ?

Thank you for any hints regarding this.

Upvotes: 0

Views: 126

Answers (1)

Cetin Basoz
Cetin Basoz

Reputation: 23797

Unfortunately, there is no direct way of doing that, even using ExecScript. Using ExecScript, you could run delete trigger code and it would return true without any errors as if it did it. But it doesn't remove the trigger, nor returns information that the trigger is still intact. Unfortunately, you can't even use ExecScript to bypass code that is otherwise not supported by the VFPOLEDB.

The only way you can do it, is to create a copy of the dbc (using VFP modify database - or C# low level if you are brave enough) and in that copy have the the same table definition without the trigger.

For example:

  • Take a copy of your existing .dbc (.dct and .dcx)

  • Modify table to remove the trigger (or do it in code:)

    Delete Trigger On ('yourTableName') For Insert
    
  • Save this .dbc, .dct and .dcx under a different name.
  • Restore existing .dbc, .dct, .dcx.
  • When you need it you could replace the .dbc, .dct, .dcx files and then put back when done.

It is cumbersome but better than nothing.

Probably you would want to instead have an VFP executable that you can call with parameters and that does the insertion for you.

Upvotes: 1

Related Questions