Calling MS-SQL Store Procedure

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
Cephas
User
Posts: 6

Calling MS-SQL Store Procedure

Post by Cephas »

Please, assist with working ASP.NET MAKER server event snippet to call store procedure. I have challenge calling a tested working paramatized MS-SQL store procedure.

Below is my test code at "Database_Connected'" server event:
private string GetID;
Execute("[bd].[sp_genBD] GetID",conn);

While the following is store procedure that is working on MS-SQL:
ALTER PROC [bd].[sp_genBD] @vBID varchar(30) OUT
AS
BEGIN
declare @getID bigint = NEXT VALUE FOR bd.BDID;
SELECT @vBDID = ltrim(a.BD_PreFix) +
REPLICATE('0', a.BD_Serial- len(ltrim(str(@getID)) ) ) +
ltrim(str(@getID)) +
rtrim(isnull(a.BD_Suffix,''))
FROM BD.tblGlb a ;
select @vBID
END;


MichaelG
User
Posts: 1110

Post by MichaelG »

ASP.NET Maker has a built in function to get the stored procedure command. So the codes should look something like:

var cmd = GetStoredProcCommand("name");
cmd.Parameters.Add("parm", type).Value = value;
cmd.Open();
cmd.ExecuteNonQuery();
//...etc...


bani06
User
Posts: 38

Post by bani06 »

Hi,

I have do some research using stored Procedure in ASP.net Maker 2021. Based on your explanation above where to use dbhelper function in code(Server event & Client scripts)?. any additional tutorial that i can study to use that?


MichaelG
User
Posts: 1110

Post by MichaelG »

You can use the codes in different server events depending on your own requirements. Please refer help file topic: Server Events and Client Scripts to understand the use of different server events.


Post Reply