URGENT: ASP Components from Visual Basic -- Help Required Please 
Author Message
 URGENT: ASP Components from Visual Basic -- Help Required Please

Hi all,

I really hope that someone out there can help me solve this really really
simple (i think) problem that i am having.

I am developing (using Visual Basic 6) a web site which uses several ASP
components and have had no problems developing my components until this new
component which needs to access the ObjectContext and Response objects

Here is a sample of some code which should work but that I am having major
problems with

  -- Visual Basic Code --

  Option Explicit

  Public Sub MySub()
    Dim oCtx As ObjectContext
    Dim oRes As Response

    Set oCtx = GetObjectContext
    Set oRes = oCtx.Item("Response")
    oRes.Write ("Hello World")
  End Sub

  -- ASP Code --

  <%
    option explicit
    dim oObj
    set oObj = Server.CreateObject("MyObj.Test")
  %>
  <html>
  <head></head>
  <body>
  <% oObj.MySub %>
  </body>
  </html>
  <% oObj = nothing %>

When I try to compile and run the Visual Basic code using the ASP page, i
get the following error

  Error 91: Object variable or With block variable not set

This is due to the fact that within my component code the oCtx variable is
never successfully set, basically GetObjectContext is always returning
"nothing"

I am sure that this is something to do with my own stupidity but I simply
cannot find a way around it!!!

Any help gratefully appreciated

Dave



Mon, 27 May 2002 03:00:00 GMT  
 URGENT: ASP Components from Visual Basic -- Help Required Please
Hello Dave,

You seems to mess up MTX and ASP.
GetObjectContext function supposed to return MTX context object. This object
doesn't have property Item and it doesn't have method 'Write'.
I would rewrite your code like this:

 -- Visual Basic Code --

 Option Explicit
 Public Function MySub()
      MySub = "Hello World"
 End Sub

 -- ASP Code --

 <%
   option explicit
   dim oObj
   set oObj = Server.CreateObject("MyObj.Test")
 %>
 <html>
 <head></head>
 <body>
 <% =oObj.MySub %>
 </body>
 </html>
 <% oObj = nothing %>

Note that your sub becomes function and you simply return Variant value.
in ASP code you use construction <%=function.call%> which will effectively
insert return value of functon into HTML body.

Regards,
Yuri


Quote:
> Hi all,

> I really hope that someone out there can help me solve this really really
> simple (i think) problem that i am having.

> I am developing (using Visual Basic 6) a web site which uses several ASP
> components and have had no problems developing my components until this
new
> component which needs to access the ObjectContext and Response objects

> Here is a sample of some code which should work but that I am having major
> problems with

>   -- Visual Basic Code --

>   Option Explicit

>   Public Sub MySub()
>     Dim oCtx As ObjectContext
>     Dim oRes As Response

>     Set oCtx = GetObjectContext
>     Set oRes = oCtx.Item("Response")
>     oRes.Write ("Hello World")
>   End Sub

>   -- ASP Code --

>   <%
>     option explicit
>     dim oObj
>     set oObj = Server.CreateObject("MyObj.Test")
>   %>
>   <html>
>   <head></head>
>   <body>
>   <% oObj.MySub %>
>   </body>
>   </html>
>   <% oObj = nothing %>

> When I try to compile and run the Visual Basic code using the ASP page, i
> get the following error

>   Error 91: Object variable or With block variable not set

> This is due to the fact that within my component code the oCtx variable is
> never successfully set, basically GetObjectContext is always returning
> "nothing"

> I am sure that this is something to do with my own stupidity but I simply
> cannot find a way around it!!!

> Any help gratefully appreciated

> Dave



Mon, 27 May 2002 03:00:00 GMT  
 URGENT: ASP Components from Visual Basic -- Help Required Please
Thanks for the answer Yuri...

In my simplified example the amount of text that was being passed back to
the ASP page was minimal and in fact, the method that you suggest is how I
have coded all of my previous ASP components.

This component however is going to be responsible for generating hundreds of
lines of HTML which I am reluctant to simply pass through a Variant (for
speed reasons amongst others)

If the ObjectContext method is for MTS only, does this mean if I register my
component with MTS I will have access to the Response object then?

Thanks
Dave


Quote:
> Hello Dave,

> You seems to mess up MTX and ASP.
> GetObjectContext function supposed to return MTX context object. This
object
> doesn't have property Item and it doesn't have method 'Write'.
> I would rewrite your code like this:

>  -- Visual Basic Code --

>  Option Explicit
>  Public Function MySub()
>       MySub = "Hello World"
>  End Sub

>  -- ASP Code --

>  <%
>    option explicit
>    dim oObj
>    set oObj = Server.CreateObject("MyObj.Test")
>  %>
>  <html>
>  <head></head>
>  <body>
>  <% =oObj.MySub %>
>  </body>
>  </html>
>  <% oObj = nothing %>

> Note that your sub becomes function and you simply return Variant value.
> in ASP code you use construction <%=function.call%> which will effectively
> insert return value of functon into HTML body.

> Regards,
> Yuri



> > Hi all,

> > I really hope that someone out there can help me solve this really
really
> > simple (i think) problem that i am having.

> > I am developing (using Visual Basic 6) a web site which uses several ASP
> > components and have had no problems developing my components until this
> new
> > component which needs to access the ObjectContext and Response objects

> > Here is a sample of some code which should work but that I am having
major
> > problems with

> >   -- Visual Basic Code --

> >   Option Explicit

> >   Public Sub MySub()
> >     Dim oCtx As ObjectContext
> >     Dim oRes As Response

> >     Set oCtx = GetObjectContext
> >     Set oRes = oCtx.Item("Response")
> >     oRes.Write ("Hello World")
> >   End Sub

> >   -- ASP Code --

> >   <%
> >     option explicit
> >     dim oObj
> >     set oObj = Server.CreateObject("MyObj.Test")
> >   %>
> >   <html>
> >   <head></head>
> >   <body>
> >   <% oObj.MySub %>
> >   </body>
> >   </html>
> >   <% oObj = nothing %>

> > When I try to compile and run the Visual Basic code using the ASP page,
i
> > get the following error

> >   Error 91: Object variable or With block variable not set

> > This is due to the fact that within my component code the oCtx variable
is
> > never successfully set, basically GetObjectContext is always returning
> > "nothing"

> > I am sure that this is something to do with my own stupidity but I
simply
> > cannot find a way around it!!!

> > Any help gratefully appreciated

> > Dave



Mon, 27 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Visual Basic With Crystal Reports - Urgent Help Please!

2. PLEASE HELP - MKS MKD etc - Urgent Help Required

3. Very basic Visual Basic help required

4. Urgent Help Required: ADO ASP and SQL7

5. Urgent Help Required PLEASE (Thanks!)

6. Visual Basic editor in word???? - Help please

7. Urgent Help Required PLEASE (Thanks!)

8. URGENT HELP REQUIRED ON VISUAL MODELER

9. Urgent Visual Basic Programmers with ASP needed for Dallas, TX

10. ADO URGENT HELP REQUIRED PLEASE.

11. Cookie code in ASP/VBScript required urgent-Help!

12. RAS Dial Up API`s In Visual Basic 5/6 [Help Required]

 

 
Powered by phpBB® Forum Software