Firstly create the stored procedure you wish to run in Azure SQL
Here’s a simple procedure which triggers and update query that inserts records into table 34 from a view based on a flag in the table saying transform is 1 it then runs another query to set the transform field to 0 to prevent the insert happening again the next time.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[transformemail]
AS
SET NOCOUNT ON;
INSERT INTO t034 (pkid,body1,eplanno,money4,trandate,payref,wlcref,tranid,email,updated)
SELECT pkid,body1,eplanno,money4,trandate,payref,wlcref,tranid,email,updated
FROM v031;
UPDATE t032email
SET transform = 0
WHERE t032email.transform = 1;
GO
Firstly navigate to the form you wish to put the code into and insert a button into that form.

Next using your mouse select the button and on the right hit the button marked Edit button code

This reveals the Button Properties window dialogue

Please note there are three tabs at the top here marked
Client Before Server and Client After – we will be placing code in all of them so take note

In the Client Before tab I enter.
params["txt"] = "Transformation";
ajax.setMessage("Sending request to server...");
// Uncomment the following line to prevent execution of "Server" and "Client After" events.
// return false;

In the Server tab I enter
tDAL.CustomQuery ("EXEC dbo.transformemail");
result["txt"] = parameters["txt"].ToString() + " complete";

And in the Client after tab I enter
// Put your code here.
var message = result["txt"] + " !!!";
ajax.setMessage(message);

Now build the project and when you hit the button on the web client your procedure will be run on the server.


