Code not executing

jnymris

New member
Joined
May 5, 2015
Messages
1
Programming Experience
5-10
Hey,

I'm having a bit of an issue with my code (see below). What happens is when I comment out everything below (excluding the final loop) ''Blast this to the database
The code works fine, However if I leave the code in (I need the code in as I need to send the data elsewhere) It does not appear to do anything (doesn't even write to the console)!

Any thoughts?

Thanks

JnyMris

VB.NET:
Do                    Dim line As String = SrRead.ReadLine()
                    If line Is Nothing Then Exit Do
                    If line = "" Then Exit Do
                    If line.Length < 1 Then Exit Do
                    Console.WriteLine("-" & line & "-")


                    ''Blast this to the Database
                    Dim request As WebRequest = WebRequest.Create(My.Settings.host & "insertTask")
                    request.Method = "POST"
                    Dim postData As String
                    postData = "computer_id=" & My.Settings.computerid & " &user_id=" & My.Settings.userid & " &log=" & line
                    Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
                    request.ContentType = "application/x-www-form-urlencoded"
                    request.ContentLength = byteArray.Length
                    Dim dataStream As Stream = request.GetRequestStream()
                    dataStream.Write(byteArray, 0, byteArray.Length)
                    dataStream.Close()
                    Dim response As WebResponse = request.GetResponse()
                    dataStream = response.GetResponseStream()
                    Dim reader As New StreamReader(dataStream)
                    ''End blast this to the database
                Loop
 
Now would be a good time to learn how to debug. If code doesn't work, you don't just read it; you watch it in action. Start by placing a breakpoint at the top of the code (F9) and then, when execution breaks, you step through the code line by line (F10). At each step, you can use various tools, e.g. the Autos, Locals and Watch windows, to evaluate the state of the app and determine where and when that diverges from your expectation. Once you know that, you can more easily determine why. Try that and post back when you have more information to provide.
 
Back
Top