Hi,I am creating OCX in VB6.0 for Http Upload.But I am getting error in HttpOpenRequest API- as "Invalid use of Null".If anyone has idea about the error Plz reply me.
I am posting my code as below. -
Public Function UploadFileHTTP(ByVal localFileName As String, ByVal remoteFileName As String) As Integer
-
'On Error Resume Next
-
Dim nRet As Integer
-
Dim nFileHandle As Integer
-
Dim sData As String
-
Dim lWritten As Long
-
Dim hConnect As Long
-
Dim hsend As Long
-
Dim nLOF As Long
-
Dim remoteFileSize As Long
-
Const BUFFER_SIZE = 1000
-
Dim s As String
-
-
sData = String(BUFFER_SIZE, 0)
-
nFileHandle = FreeFile
-
-
hConnect = InternetConnect(hInternet, sData, INTERNET_DEFAULT_HTTP_PORT, "", "", INTERNET_SERVICE_HTTP, 0, 0)
-
'The function sends request to get data.
-
hRequest = HttpOpenRequest(hConnect, "GET", remoteFileName, "", Null, Null, INTERNET_FLAG_RELOAD, 0)
-
-
'Read data from local buffer
-
Open localFileName For Binary Access Write As nFileHandle
-
nLOF = LOF(nFileHandle) + 1
-
s = Space(nLOF)
-
Get #nFileHandle, nLOF, s
-
'Write to server
-
nRet = InternetWriteFile(hRequest, s, BUFFER_SIZE, lWritten)
-
Close hRequest
-
Close nFileHandle
-
InternetCloseHandle hConnect
-
End Function
4 2108
Which line is throwing the error ?
Which line is throwing the error ?
Line number 19--HttpOpenRequest()
Please find more about HttpOpenRequest here and here .
Please find more about HttpOpenRequest here and here .
When I I enter parameter server name in HttpConnect API,then my apllication get hang also I am grtting hConnect as 0 why so?any idea?I am posting my code as below--- - Public Function OpenConnectionHTTP(ByVal HttpServerName As String) As Boolean
-
Dim openHttpFlags As Long
-
hInternet = InternetOpen(App.EXEName, INTERNET_OPEN_TYPE_PROXY, vbNullString, vbNullString, 0)
-
If hInternet = 0 Then
-
LastDllErrorInfo 'Call before calling any other dll function
-
If Not HttpErrorCode = 0 Then
-
Err.Raise HttpErrorCode, , HttpErrorString
-
End If
-
Exit Function
-
Else
-
openHttpFlags = 0
-
If lPassiveMode = True Then
-
openHttpFlags = openHttpFlags
-
End If
-
hConnect = InternetConnect(hInternet, HttpServerName, INTERNET_DEFAULT_HTTP_PORT, "", "", INTERNET_SERVICE_HTTP, 0, 0)//Getting error in this statement(When I enter parameter Httpserver name in apllication get hang,also hconnect is 0.)
-
End If
-
-
-
OpenConnectionHTTP = True
-
End Function
-
Public Function UploadFileHTTP(ByVal localFileName As String, ByVal remoteFileName As String) As Integer
-
Dim nRet As Integer
-
Dim nFileHandle As Integer
-
Dim sData As String
-
Dim lWritten As Long
-
Dim bData(BUFFER_SIZE - 1) As Byte
-
Dim leftoversize As Long
-
-
Dim nLOF As Long
-
Dim remoteFileSize As Long
-
-
sData = String(BUFFER_SIZE, 0)
-
nFileHandle = FreeFile
-
-
-
If hConnect <> 0 Then
-
hRequest = HttpOpenRequest(hConnect, "GET", remoteFileName, "HTTP/1.0", Null, AccessTypes.AccessType_Write, INTERNET_FLAG_HYPERLINK, 0)
-
End If
-
-
'Read data from local buffer
-
Open localFileName For Binary As nFileHandle
-
nLOF = LOF(nFileHandle) + 1
-
's = Space(nLOF)
-
leftoversize = nLOF
-
Get #nFileHandle, , bData
-
-
'Write to server
-
If leftoversize <> 0 Then
-
nRet = InternetWriteFile(hRequest, remoteFileName, bData(0), lWritten)
-
End If
-
-
If nRet = 0 Then
-
Close #nFileHandle
-
End If
-
-
Close hRequest
-
-
InternetCloseHandle hConnect
-
End Function
-
Public Sub CloseConnectionHTTP()
-
InternetCloseHandle hConnect
-
InternetCloseHandle hInternet
-
hInternet = 0
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Thomas Barth |
last post by:
Hi,
I'm new to windows programming and still reading a book about
windows-programming with C++. I copied the following code from
the book into my ide (Eclipse/CDT) to comprehend the code, but
two...
|
by: Patrick Dunnigan |
last post by:
Hi,
I am attempting a bulk copy from a c program into SQL Server 2000 using
DBLib in freeTDS 0.63 RC11 (gcc 3.4.3, RH 9). I am getting an error message
that I cannot find any documentation on.
...
|
by: headware |
last post by:
I'm getting a weird problem in an Access query. I have a table that
contains a field calle F1 that's a 2 character text field. The first
character is always a number. What I'd like to do is find...
|
by: Frank Perry |
last post by:
Howdy,
I'm trying to write data out the com port. I have taken the code from the
sample on the MSDN Library CD and used the parts that seem relevant. I can
open the com port with CreateFile...
|
by: Jerry |
last post by:
Below is ALL the code for all the databases...
Here's the problem:
I callup the aspx file in IE and the form comes up just fine. When I
select a person to update, I get the subject error. ...
|
by: David |
last post by:
Hi,
I have built a web application that will be a very high profile application.
We had tested it, demonstrated it and shown that it all works.
On a dress rehearsal run through, it failed...
|
by: Jamie |
last post by:
I am receiving an Invalid ViewState error after posting back to the same page
twice. Consistently the error occurs after the second postback and not after
the first.
I have looked into creating...
|
by: KWienhold |
last post by:
I'm currently working on a project in C# (VS 2003 SP1, .Net 1.1) that
utilizes IStream/IStorage COM-Elements.
Up to now I have gotten everything to work to my satisfaction, but now
I have come...
|
by: shrik |
last post by:
I have following error :
Total giant files in replay configuration file are :
File name : /new_file/prob1.rec
Given file /new_file/prob1.rec is successfully verified.
Splitting for giant file...
|
by: rando1000 |
last post by:
I'm pulling data from a field on a form, evaluating whether or not it's null, then calculating based on the data in the field. Here's my code for evaluating the field:
intAdvanced = IIf(Not...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |