mobile databases, mobile forms, and mobile synchronization … where you need to work
Providing Pocket Access, Mobile Database, Windows CE Database, and Windows CE Development Solutions

Tip of the Month (May 2009)

Executing a SQL Server Stored Procedure

If your server database is a SQL Server database, it might have a stored procedure you would want run from your handheld. Of course, this stored procedure can only be started when the handheld "touches" the SQL Server (that is, during a synchronization and/or when a form is using mEnable). Setting this up is pretty straight forward:

  1. On your SQL Server, create your stored procedure:

        CREATE PROCEDURE MyProcedure AS <<SQL Statement>>

    If you never created a stored procedure before, you may want to look at this stored procedure tutorial.

  2. In SQL Server, create a table called MyTable. It should have one column (MyColumn) and one row of data in it.

  3. Create a trigger over that table:

        CREATE TRIGGER MyTrigger ON MyTable FOR UPDATE AS EXEC MyProcedure

    If you never created a trigger before, you may want to look at this trigger tutorial.

Then, create a form over MyTable and download it to the handheld. Run this form on the handheld and modify MyColumn. If the form you created over MyTable is not an mEnable "Always Connected" form, synchronize MyTable.

The synchronizer or mEnable will modify MyColumn. This will cause MyTrigger to fire. MyTrigger will run MyProcedure.


Previous Tips of the Month