Board index » cppbuilder » ActiveX and ASP and Request object

ActiveX and ASP and Request object


2004-02-21 02:24:47 PM
cppbuilder44
The code below should simulate ASP's QueryString, but the return value is 0.
// MYTESTIMPL : Implementation of TMyTestImpl
#include <vcl.h>
#pragma hdrstop
#include "MYTESTIMPL.H"
/////////////////////////////////////////////////////////////////////////////
// TMyTestImpl
STDMETHODIMP TMyTestImpl::Method1(long* Param1)
{ int t;
CComPtr<IRequestDictionary>RD;
Request->get_QueryString(&RD);
AnsiString S = "user";
char buf[20];
RD->get_Item((tagVARIANT)(Variant)"user", (tagVARIANT*)(&buf));
AnsiString SV = buf;
Response->Write(Variant(WideString(S + ":" + SV)));
*Param1 =atol(buf);
return S_OK;
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
ASP Code
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<HTML>
<HEAD>
<TITLE>Testing C++Builder ASP </TITLE>
</HEAD>
<BODY>
<CENTER>
<H3>You should see the results of your C++Builder Active Server method below </H3>
</CENTER>
<HR>
<% Set CBuilderASPObj = Server.CreateObject("Project1.MyTest")
dim y
y = CBuilderASPObj.Method1()
response.write y
%>
<form name="input" action="default.asp"
method="get">
Username:
<input type="text" name="user">
<input type="submit" value="Submit">
</form>
</BODY>
</HTML>
 
 

Re:ActiveX and ASP and Request object

"Fernando Villa" < XXXX@XXXXX.COM >wrote in message
Quote
RD->get_Item((tagVARIANT)(Variant)"user", (tagVARIANT*)(&buf));
You are misusing Variant and tagVARIANT, especially in regards to the output
value of get_Item(). You can't simply cast a char[] to a Variant, that is
not how Variants work. Try the following code instead:
VARIANT Query;
RD->get_Item(Variant(WideString("user")), &Query);
AnsiString SV = Variant(Query);
::VariantClear(&Query);
Response->Write(Variant(WideString("user:" + SV)));
*Param1 = SV.ToIntDef(0);
Alternatively:
TVariant Query;
RD->get_Item(Variant(WideString("user")), Query);
AnsiString SV = Query;
Response->Write(Variant(WideString("user:" + SV)));
*Param1 = SV.ToIntDef(0);
Gambit
 

Re:ActiveX and ASP and Request object

It's working, thanks.
 

{smallsort}