473,322 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Invalid use of Null

27
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.

Expand|Select|Wrap|Line Numbers
  1. Public Function UploadFileHTTP(ByVal localFileName As String, ByVal remoteFileName As String) As Integer
  2. 'On Error Resume Next
  3.     Dim nRet As Integer
  4.     Dim nFileHandle As Integer
  5.     Dim sData As String
  6.     Dim lWritten As Long
  7.     Dim hConnect As Long
  8.     Dim hsend As Long
  9.     Dim nLOF As Long
  10.     Dim remoteFileSize As Long
  11.     Const BUFFER_SIZE = 1000
  12.     Dim s As String
  13.  
  14.     sData = String(BUFFER_SIZE, 0)
  15.     nFileHandle = FreeFile
  16.  
  17.     hConnect = InternetConnect(hInternet, sData, INTERNET_DEFAULT_HTTP_PORT, "", "", INTERNET_SERVICE_HTTP, 0, 0)
  18.     'The function sends request to get data.
  19.     hRequest = HttpOpenRequest(hConnect, "GET", remoteFileName, "", Null, Null, INTERNET_FLAG_RELOAD, 0)
  20.  
  21.     'Read data from local buffer
  22.     Open localFileName For Binary Access Write As nFileHandle
  23.     nLOF = LOF(nFileHandle) + 1
  24.     s = Space(nLOF)
  25.     Get #nFileHandle, nLOF, s
  26.     'Write to server
  27.     nRet = InternetWriteFile(hRequest, s, BUFFER_SIZE, lWritten)
  28.     Close hRequest
  29.     Close nFileHandle
  30.     InternetCloseHandle hConnect
  31. End Function
Mar 17 '08 #1
4 2108
debasisdas
8,127 Expert 4TB
Which line is throwing the error ?
Mar 17 '08 #2
Swan
27
Which line is throwing the error ?

Line number 19--HttpOpenRequest()
Mar 17 '08 #3
debasisdas
8,127 Expert 4TB
Please find more about HttpOpenRequest here and here .
Mar 17 '08 #4
Swan
27
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---


Expand|Select|Wrap|Line Numbers
  1. Public Function OpenConnectionHTTP(ByVal HttpServerName As String) As Boolean
  2.     Dim openHttpFlags As Long
  3.     hInternet = InternetOpen(App.EXEName, INTERNET_OPEN_TYPE_PROXY, vbNullString, vbNullString, 0)
  4.     If hInternet = 0 Then
  5.         LastDllErrorInfo 'Call before calling any other dll function
  6.         If Not HttpErrorCode = 0 Then
  7.             Err.Raise HttpErrorCode, , HttpErrorString
  8.         End If
  9.         Exit Function
  10.     Else
  11.         openHttpFlags = 0
  12.         If lPassiveMode = True Then
  13.             openHttpFlags = openHttpFlags
  14.         End If
  15.         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.)
  16.     End If
  17.  
  18.  
  19.     OpenConnectionHTTP = True
  20. End Function
  21. Public Function UploadFileHTTP(ByVal localFileName As String, ByVal remoteFileName As String) As Integer
  22.     Dim nRet As Integer
  23.     Dim nFileHandle As Integer
  24.     Dim sData As String
  25.     Dim lWritten As Long
  26.     Dim bData(BUFFER_SIZE - 1) As Byte
  27.     Dim leftoversize As Long
  28.  
  29.     Dim nLOF As Long
  30.     Dim remoteFileSize As Long
  31.  
  32.     sData = String(BUFFER_SIZE, 0)
  33.     nFileHandle = FreeFile
  34.  
  35.  
  36.     If hConnect <> 0 Then
  37.     hRequest = HttpOpenRequest(hConnect, "GET", remoteFileName, "HTTP/1.0", Null, AccessTypes.AccessType_Write, INTERNET_FLAG_HYPERLINK, 0)
  38.     End If
  39.  
  40.     'Read data from local buffer
  41.     Open localFileName For Binary As nFileHandle
  42.     nLOF = LOF(nFileHandle) + 1
  43.     's = Space(nLOF)
  44.     leftoversize = nLOF
  45.     Get #nFileHandle, , bData
  46.  
  47.     'Write to server
  48.     If leftoversize <> 0 Then
  49.     nRet = InternetWriteFile(hRequest, remoteFileName, bData(0), lWritten)
  50.     End If
  51.  
  52.     If nRet = 0 Then
  53.     Close #nFileHandle
  54.     End If
  55.  
  56.     Close hRequest
  57.  
  58.     InternetCloseHandle hConnect
  59. End Function
  60. Public Sub CloseConnectionHTTP()
  61.     InternetCloseHandle hConnect
  62.     InternetCloseHandle hInternet
  63.     hInternet = 0
  64. End Sub
Mar 18 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
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...
1
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. ...
2
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...
3
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...
0
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. ...
15
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...
9
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...
6
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...
0
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...
3
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
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...
0
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...
1
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)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
0
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.