Results 1 to 2 of 2

Thread: Code not executing

  1. #1
    jnymris is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.5
    Join Date
    May 2015

    Code not executing


    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?



    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( & "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)
                        Dim response As WebResponse = request.GetResponse()
                        dataStream = response.GetResponseStream()
                        Dim reader As New StreamReader(dataStream)
                        ''End blast this to the database

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Sydney, Australia
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts