c++ - SQLBindParameter for output varchar -
i have stored procedure has varchar
output parameter:
@useridout varchar(50) output
and in c++ code attempt bind output parameter this:
... sqlchar useridout[50]; int dbreturn = execproc(...(sqlchar**)&useridout); ... int execproc(...sqlchar **useridout) { ... sqlinteger cbparam7 = sql_nts; retcode = sqlbindparameter(hstmt1, 7, sql_param_output, sql_c_char, sql_varchar, 50, 0, *useridout, 50, &cbparam7); retcode = sqlexecdirect(hstmt1, (uchar*)"{? = call updateuser(?,?,?,?,?,?)}", sql_nts);
i have several other input parameters, , return value stored procedure. i've tried few variations function call, , yet never in useridout
. if execute stored procedure sql server proper output.
any thoughts?
per comments:
you need pass pointer useridout
sqlbindparameter
. passing isn't pointer useridout
, rather, first bytes of useridout
reinterpreted pointer.
an array implicitly converted pointer first element (and since array stored contiguously in memory, makes rest of data accessible too), don't need write &useridout
, can write useridout
if change type sqlchar *
.
int execproc(..., sqlchar *useridout) { ... ... sqlbindparameter(..., useridout, 50, &cbparam7); ... } // call ... execproc(..., useridout);
you could, if wish, continue work pointer useridout
, requires use pointer array, not pointer pointer, , pointers arrays use awkward syntax , don't have more value pointers 1 of array's elements:
int execproc(..., sqlchar (*useridout)[50]) { ... ... sqlbindparameter(..., useridout, 50, &cbparam7); ... } // call ... execproc(..., &useridout);
Comments
Post a Comment