Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SOLUTION !!! POSTing to an ASP page through INET control in VB6

760 views
Skip to first unread message

Von Strumpf

unread,
Jun 17, 1999, 3:00:00 AM6/17/99
to

Hello

Who want's to know how to use the Inet Control to SEND POST information to
an ASP page?
i guess a lot of people.... well here's the solution !!!

HINT: the trick is in the "strContent" variable... watch the code.....

Create a form and put the INET Control on it and a Command button.

Then paste this code:

----------------------------------------------------------------------------
-----------------------------------------------
Option Explicit

Private Sub Command1_Click()
Dim strURL As String, strData As String, strContent as string

strURL = "http://localhost/testdir/getpost.asp"
strData = "Value1=test1&Value2=test2"
strContent = "Content-Type:application/x-www-form-urlencoded"
Inet1.Execute strURL, "POST", strData , strContent
End Sub


Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData As Variant ' Data variable.

Select Case State
Case icError ' 11
' In case of error, return ResponseCode and
' ResponseInfo.
vtData = Inet1.ResponseCode & ":" & _
Inet1.ResponseInfo

Case icResponseCompleted ' 12
Dim strData As String: strData = ""
Dim bDone As Boolean: bDone = False

' Get first chunk.
vtData = Inet1.GetChunk(1024, icString)
DoEvents

Do While Not bDone

strData = strData & vtData
' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
DoEvents

If Len(vtData) = 0 Then
bDone = True
End If
Loop

MsgBox strData
End Select
End Sub

Private Sub Form_Load()
Inet1.Cancel
End Sub
----------------------------------------------------------------------------
-----------------------------------------------

Then Create an ASP page named GETPOST.ASP and paste this code:
----------------------------------------------------------------------------
-----------------------------------------------
<HTML>
<HEAD>
<TITLE>test asp</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF>
<H3>inet control Test</H3>
The first value is
<% =Request("value1") %>
<BR>
second value is
<% =Request("value2") %>
</BODY>
</HTML>
----------------------------------------------------------------------------
-----------------------------------------------


and VOILÁ! you've passed the two values to the request object in an ASP....
now you can store those values in a recordset, for example.

I hope you've enjoyed it.....

please post any comments in this thread...... my email doesn't work :))))

and if you want to know more about it go to MSDN - Knowledge Base
and search for this article:

"Q175474 - INFO Header Required Posting HTML Form Encoded Data to ASP Page"


"Don't waste time! Erase those NOP's........"
( a little bit-head advice to those Microsoft Developers)


O============O
Von Strumpf
O============O


Jeff Hsu

unread,
Jul 1, 1999, 3:00:00 AM7/1/99
to
Von,

I'm trying to implement the control within a COM object but because of the
asynchronous behavior of the EXECUTE method, my COM object completes its
lifcycle before the Inet control completes its process.
(the control resides on an unseen form and is called with a single class
module)

Any advice on implementing the control within COM or the asyncronous
tranmissiuon method of Inet?

-Jeff


Von Strumpf wrote in message ...

0 new messages