Make a Stored Procedure Call using .NET SDK


#1

Hi,

I can see StoredProcRequest() in the .Net SDK, how do I use this to call a SQL Server stored procedure, with and without params?

Thanks for your help,
Matt


REST API Architecture (.net service wrapper)
#2

Hi Matt,

First of all you want to instantiate RestContext and use the Factory to create an instance of DatabaseApi. Then you can call any of the CallStoredProc overloads. Following code snippet might help you get going.

IRestContext context = new RestContext("http://localhost:8080"); IDatabaseApi databaseApi = context.Factory.CreateDatabaseApi("my_db_service_name");

await databaseApi.CallStoredProcAsync(“my_stored_proc_without_params”);

StoreProcParamsBuilder builder = new StoreProcParamsBuilder();
builder.WithInParam(“id”, 1);
ResultDTO result = await databaseApi.CallStoredProcAsync(“my_stored_proc_with_param”, builder.Build());

Hope this helps.

Regards,
Marko


#3

Hi Marko,

Really appreciate you taking the time to reply thanks.

I am trying the no params call first and getting -

500 - Failed to call database stored procedure.
SQLSTATE[IMSSP]: The active result for the query contains no fields.

So at least thats a start, hope progress further when get a moment tommorow.

Thanks
Matt