Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 5th, 2003, 09:53 AM
otiliam otiliam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 6 otiliam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Why should I get "Run-time error 6"?

I successfully registered a .dll, called HttpServices.dll which includes functions for connecting to a mail server, with regsrv.
When I try to run the following ASP code:
<%
'Option Explicit
Response.Buffer = True

'Get the application id from query string
Dim iAppId
iAppId = Request.QueryString("appid")

'If appid exists then login to that application
If Request.QueryString("appid") <> "" Then
'
'Here you shoul get all configuration data for the application from the database
'
Dim objHttp
Dim sAppURL
Dim sServer
Dim sPort
Dim sLoginUserVar
Dim sLoginUser
Dim sLoginPwdVar
Dim sLoginPwd
Dim sLoginPage
Dim sLoginMethod
Dim bResult

'set the application URL
sAppURL = "http://localhost:32000/mail"
'set server name for the http connection
sServer = "localhost"
'set the server port
sPort = 32000
'set the username for login
sLoginUserVar = "username"
sLoginUser = "admin"
'set the password for login
sLoginPwdVar = "password"
sLoginPwd = "admin"
'set the application login page
sLoginPage = "/mail/login.html"
'set the method of sending login data
sLoginMethod = "POST"

'create a HTTP object to send and receive data from the application
Set objHttp = Server.CreateObject("HttpServices.HttpPost")

'check for a connection to server
On Error Resume Next
bResult = objHttp.CheckConnection (sAppUrl)
On Error GoTo 0
If Not bResult Then
'there is no connection to server
Response.Write "No connection to server"
End If

'configure and open a connection to the server
objHttp.ServerName = sServer
objHttp.ServerPort = sPort
objHttp.OpenConnection

If Request.QueryString("page") = "" Then
'login to application
Dim sHeader
Dim sData
'add a request header
sHeader = "Content-Type: application/x-www-form-urlencoded"
'add login data
sData = sLoginUserVar & "=" & sLoginUser & "&" & sLoginPwdVar & "=" & sLoginPwd
'create and send the request
objHttp.CreateRequest sLoginPage, sLoginMethod
objHttp.AddRequestHeader sHeader, Len(sHeader)
objHttp.SendRequest sData, Len(sData)
Else
'get the desired page
objHttp.CreateRequest "/mail/" & Request.QueryString("page"), "GET"
objHttp.SendRequest
End If

Else

End If

'Response.End

strResponseHeaders = Split(objHttp.GetInfo(22), Chr(13) & Chr(10))
For i = 0 To UBound(strResponseHeaders)
'Response.Write strResponseHeaders(i) & "<br>"
If InStr(strResponseHeaders(i), ":") > 0 Then
strHeader = Split(strResponseHeaders(i), ":")
'Response.Write "->" & strHeader(0) & ":" & Trim(strHeader(1)) & "<br>"
Response.AddHeader Trim(strHeader(0)), Trim(strHeader(1))
End If
Next

Response.Flush

strHtml = ""
Do
strResponse = objHttp.GetChunk
strHtml = strHtml & strResponse
Loop While strResponse <> ""

strNewHtml = ""

Set objParser = Server.CreateObject("HttpServices.HtmlParser")

objParser.HtmlToParse = strHtml
objParser.Parse

Dim Tag
Dim Attrib
Dim lngLastPos

lngLastPos = 1

For Each Tag In objParser.HtmlTag
For Each Attrib In Tag.Attributes
If (UCase(Tag.TagName) = "LINK" And UCase(Attrib.TagAttribute) = "HREF") Or _
(UCase(Tag.TagName) = "IMG" And UCase(Attrib.TagAttribute) = "SRC") Or _
(UCase(Tag.TagName) = "SCRIPT" And UCase(Attrib.TagAttribute) = "SRC") Then

If lngLastPos > 0 Then
strNewHtml = strNewHtml & Mid(strHtml, lngLastPos, Attrib.Position - lngLastPos)
End If
strNewHtml = strNewHtml & "http://localhost:32000/mail/"
lngLastPos = Attrib.Position
End If

If UCase(Tag.TagName) = "A" And UCase(Attrib.TagAttribute) = "HREF" Then
If lngLastPos > 0 Then
strNewHtml = strNewHtml & Mid(strHtml, lngLastPos, Attrib.Position - lngLastPos)
End If

strQuery = "page=" & Server.URLEncode(Attrib.AttributeValue)

strNewHtml = strNewHtml & "loader.asp?" & strQuery
lngLastPos = Attrib.Position
lngLastPos = lngLastPos + Len(Attrib.AttributeValue)
End If
Next
Next
If lngLastPos > 0 Then
strNewHtml = strNewHtml & Mid(strHtml, lngLastPos)
End If

Response.Write strNewHtml

Set objHttp = Nothing
%>

I get the "Run-time error '6'", which err.description I can not find. It also says "check WinInet reference".
Any ideas?

Thanks. Otilia

Reply With Quote
  #2  
Old December 5th, 2003, 09:55 AM
otiliam otiliam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 6 otiliam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I forgot to say that the error is on line : strResponseHeaders = Split(objHttp.GetInfo(22), Chr(13) & Chr(10)).

Otilia

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Why should I get "Run-time error 6"?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT