This topic is locked

Calling a Stored Procedure from ASPRunnerPro / Button to call Stored Procedure - No answers?

8/14/2024 6:53:06 AM
ASPRunnerPro General questions
C
Conrunner author

Hello there - No answers to this at all?

I have a stored procedure on a Microsoft SQL Server database which runs fine when executed from MSSQL Management Suite. For the life of me however I cannot seem to get the stored procedure to run by inserting code in the events section of ASPRunnerPro. I have looked on the internet and there seem to be several different options for code, I have tried all of them, but none of them seem to work as they all result in errors and I wondered if anybody could possibly tell me what the correct code to run a stored procedure is? I am using the most recent version of ASPRunnerPro. The stored procedure is very simple; it just truncates a table. No parameters.

Also I wondered if anybody could direct me toward guidance on how to get a custom button to run a stored procedure when the button is clicked? I do have the ASPRunnerPro manual but I do find it rather confusing I am afraid.

I would be extremely grateful for any wants help or suggestions.

Thx

Con

J
jackwood 8/14/2024

Maybe this is the solution.
To create a custom button that triggers the stored procedure when clicked:

Add a Custom Button:

In ASPRunnerPro, go to the page where you want to add the button (e.g., List Page).
Add a custom button through the Visual Editor.
Attach the Code to the Button:

After adding the button, go to the Server section of the button's properties.
Add the following code:

php

global $conn;

$sql = "{call your_stored_procedure_name}";
$result = db_exec($sql, $conn);

if (!$result) {
echo "Error executing stored procedure: " . db_error($conn);
} else {
echo "Procedure executed successfully!";
}
This will run the stored procedure when the button is clicked, and you will see a success message if it runs successfully.

Sergey Kornilov admin 8/15/2024

Start here:
https://xlinesoft.com/asprunnerpro/docs/how_to_execute_stored_procedures_from_events.htm

It is hard to understand how adding a single line of code to your event can be confusing. You need to show the exact code you use and exact results you are getting.