BYTE* to BSTR

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I'm not a c++ programmer, but I find myself writing an extended stored
procedure to call a web service. I got this part working.

I want to pass parameters through the extended proc on to the web service.

The params come in through a BYTE* param in here (pData):
srv_paraminfo(pSrvProc, 1, &cType, &uMaxLen, &uLen, pData, &fNull);

I need to send them to the web service using a BSTR datatype.

How can I accomplish this?

Thanks.
 
EdInPhoenix said:
Hi All,

I'm not a c++ programmer, but I find myself writing an extended stored
procedure to call a web service. I got this part working.

I want to pass parameters through the extended proc on to the web service.

The params come in through a BYTE* param in here (pData):
srv_paraminfo(pSrvProc, 1, &cType, &uMaxLen, &uLen, pData, &fNull);

I need to send them to the web service using a BSTR datatype.

How can I accomplish this?

Thanks.

Can you give the following functions prototypes?
srv_paraminfo(pSrvProc, 1, &cType, &uMaxLen, &uLen, pData, &fNull);
Prototype means, complete function signature, with return data type, and parameter types.
 
Tom Alter said:
Can you give the following functions prototypes?
srv_paraminfo(pSrvProc, 1, &cType, &uMaxLen, &uLen, pData, &fNull);
Prototype means, complete function signature, with return data type, and parameter types.

Thanks Tom,
This is from the SQL Server Books online:
-----------------------------------------------
srv_paraminfo
Returns information about a parameter.



Important This function supersedes the following Open Data Services
functions: srv_paramtype, srv_paramlen, srv_parammaxlen, and srv_paramdata.
srv_paraminfo supports the new Data Types and zero-length data.


Syntax
int srv_paraminfo (
SRV_PROC * srvproc,
int n,
BYTE * pbType,
ULONG * pcbMaxLen,
ULONG * pcbActualLen,
BYTE * pbData,
BOOL * pfNull );

Arguments
srvproc

A handle for a client connection.

n

The ordinal number of the parameter to be set. The first parameter is 1.

pbType

The data type of the parameter.

pcbMaxLen

Pointer to the maximum length of the parameter.

pcbActualLen

Pointer to the actual length of the parameter. A value of 0 (*pcbActualLen
== 0 ) signifies zero-length data if *pfNull is set to FALSE.

pbData

Pointer to the buffer for parameter data. If pbData is not NULL, Open Data
Services writes *pcbActualLen bytes of data to *pbData. If pbData is NULL, no
data is written to *pbData but the function returns *pbType, *pcbMaxLen,
*pcbActualLen, and *pfNull. The memory for this buffer must be managed by the
Open Data Services application.

pfNull

Pointer to a null flag. *pfNull is set to TRUE if the value of the parameter
is NULL.

Returns
If the parameter information was successfully obtained, SUCCEED is returned;
otherwise, FAIL. FAIL is returned when there is no current remote stored
procedure and when there is no nth remote stored procedure parameter.

©1988-2000 Microsoft Corporation. All Rights Reserved.
 
EdInPhoenix said:
Thanks Tom,
This is from the SQL Server Books online:
-----------------------------------------------
srv_paraminfo
Returns information about a parameter.



Important This function supersedes the following Open Data Services
functions: srv_paramtype, srv_paramlen, srv_parammaxlen, and srv_paramdata.
srv_paraminfo supports the new Data Types and zero-length data.


Syntax
int srv_paraminfo (
SRV_PROC * srvproc,
int n,
BYTE * pbType,
ULONG * pcbMaxLen,
ULONG * pcbActualLen,
BYTE * pbData,
BOOL * pfNull );

Arguments
srvproc

A handle for a client connection.

n

The ordinal number of the parameter to be set. The first parameter is 1.

pbType

The data type of the parameter.

pcbMaxLen

Pointer to the maximum length of the parameter.

pcbActualLen

Pointer to the actual length of the parameter. A value of 0 (*pcbActualLen
== 0 ) signifies zero-length data if *pfNull is set to FALSE.

pbData

Pointer to the buffer for parameter data. If pbData is not NULL, Open Data
Services writes *pcbActualLen bytes of data to *pbData. If pbData is NULL, no
data is written to *pbData but the function returns *pbType, *pcbMaxLen,
*pcbActualLen, and *pfNull. The memory for this buffer must be managed by the
Open Data Services application.

pfNull

Pointer to a null flag. *pfNull is set to TRUE if the value of the parameter
is NULL.

Returns
If the parameter information was successfully obtained, SUCCEED is returned;
otherwise, FAIL. FAIL is returned when there is no current remote stored
procedure and when there is no nth remote stored procedure parameter.

©1988-2000 Microsoft Corporation. All Rights Reserved.

After much nashing of teeth I came upon this solution, part of which was
from another thread:
srv_paraminfo(srvproc, 1, &bType, &uMaxLen, &uLen, Data, &bNull);
CAtlString CAApplication( (LPCSTR)(const char *) Data, uLen );
BSTR sApplication = CAApplication.AllocSysString();

The key was the casting of the Data pointer.
 
EdInPhoenix said:
Hi All,

I'm not a c++ programmer, but I find myself writing an extended stored
procedure to call a web service. I got this part working.

I want to pass parameters through the extended proc on to the web service.

The params come in through a BYTE* param in here (pData):
srv_paraminfo(pSrvProc, 1, &cType, &uMaxLen, &uLen, pData, &fNull);

I need to send them to the web service using a BSTR datatype.

How can I accomplish this?

Thanks.

bstr_t
 
Back
Top