How to execute the parameterized stored procedure in SQLExecDirect

1.3k Views Asked by At

I want to execute a stored procedure using SQLExecDirect().

So I am setting the input parameter using SQLBindParameter(). Also I am using SQL_PARAM_OUTPUT to bind the output parameter.

But after executing the query, I am getting SQL_ERROR. Here is the code.

SQLBindParameter(hStmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, 
                                         SQL_CHAR , 40, 0, name, sizeof(name) ,
                                         SQL_NULL_HANDLE);

SQLBindParameter(hStmt, 2, SQL_PARAM_OUTPUT, SQL_C_CHAR, 
                                         SQL_CHAR , 40, 0, userSID, sizeof(userSID) ,
                                         SQL_NULL_HANDLE);

r = SQLExecDirect(hStmt, "{ call Stored_procedure(?,?)}", SQL_NTS) ;

Stored_procedure will take 1 input parameter and also returns 1 output parameter it also return output.

I am able to execute this stored procedure. But I'm unable to get the value of the output parameters in the stored procedure.

0

There are 0 best solutions below