September 28, 2005 at 7:32 pm
EXEC @retval = master..xp_test 255
SELECT @retval -- returns 255 (OK)
EXEC @retval = master..xp_test 257
SELECT @retval -- returns 1 (WHY?)
Proc = srvproc;
LONG forit = 0;
BYTE bType = 0;
ULONG ulMaxLen = 0;
ULONG ulActualLen = 0;
BOOL isParamNull = FALSE;
int inputParamIndex = 1;
rc = srv_paraminfo(Proc, inputParamIndex, &bType
, &ulMaxLen, &ulActualLen, NULL, &isParamNull);
// Create memory to get the long parameters into.
BYTE* ldata = new BYTE[ulMaxLen];
memset(ldata, '\0', ulMaxLen);
rc = srv_paraminfo(Proc, inputParamIndex, &bType
, &ulMaxLen, &ulActualLen, ldata, &isParamNull);
forit = (LONG)*ldata;
delete []ldata;
return forit;
September 29, 2005 at 10:07 am
If you use constant as parameter, you can try to cast it to int. Or declare a variable.
DECLARE @retval int
DECLARE @Param int
SET @Param=255
EXEC @retval = master..xp_test @Param
SELECT @retval -- returns 255 (OK)
SET @Param=257
EXEC @retval = master..xp_test @Param
SELECT @retval
September 29, 2005 at 10:27 am
Alas, if it were only that easy, but that does not work either. The problem is in the C code itself.
Thanks
September 29, 2005 at 10:57 am
Can you print the ulActualLen and ldata after get the parameter in the xp by srv_sendmsg?
September 29, 2005 at 11:15 am
I am walking through with the debugger -
bType = 38
ulMaxLen = 4
ulActualLen = 4
lData = 2
szServerCodePage = "850"
September 29, 2005 at 11:37 am
I have figured it out, and it is indeed my error. I was defining ldata as a BYTE*, not a ULONG*
Corrected code fragment is:
ULONG* ldata = new ULONG[ulMaxLen];
memset(ldata, '\0', ulMaxLen);
rc = srv_paraminfo(Proc, inputParamIndex, &bType
, &ulMaxLen, &ulActualLen, (BYTE*)ldata, &isParamNull);
forit = (LONG)*ldata;
delete []ldata;
Thanks
Ric
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply