Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

BYTE* to BSTR

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EdInPhoenix - 06 May 2005 04:45 GMT
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.
Tom Alter - 06 May 2005 07:04 GMT
> Hi All,
>
[quoted text clipped - 11 lines]
>
> 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.
EdInPhoenix - 06 May 2005 13:16 GMT
> > Hi All,
> >
[quoted text clipped - 15 lines]
> 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 - 06 May 2005 19:31 GMT
> > > Hi All,
> > >
[quoted text clipped - 77 lines]
>
> ©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.
beginthreadex - 06 May 2005 20:09 GMT
> Hi All,
>
[quoted text clipped - 11 lines]
>
> Thanks.

bstr_t
Signature

new


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.