2

I still looking for the answer, while I'm still trying this Visual Studio to develop some web app using VB.net language...

hmmm.... I actually wanted to printout my catch message, but somehow, if I put this one...

 Try
        Dim oCommand As MySqlCommand = New MySqlCommand("SELECT * FROM suppliermst WHERE supplierid = " & p_iSupplierId, oConnection)
        oConnection.Open()
        oReader = oCommand.ExecuteReader

        While oReader.Read
            oSuppliermst = New suppliermst
            oSuppliermst.supplierId = oReader("supplierid")
            oSuppliermst.name = oReader("name")
            oSuppliermst.state = oReader("state")
            oSuppliermst.telNo = oReader("telno")
            oSuppliermst.mobileNo = oReader("mobileno")
            oSuppliermst.faxNo = oReader("faxno")
            oSuppliermst.email = oReader("email")
            oSuppliermst.countryCode = oReader("countrycode")
            oSuppliermst.companyName = oReader("companyname")
            oSuppliermst.city = oReader("city")
            oSuppliermst.address1 = oReader("address1")
            oSuppliermst.address2 = oReader("address2")
            oSuppliermst.postCode = oReader("postcode")
        End While

    Catch ex As Exception
        'log here
        Console.WriteLine("error on getSuppliermstBySupplierId() function" & ex.Message)

    Finally
        closeMySqlDataReader(oReader)
        closeMySqlConnection(oConnection)
    End Try

The Catch doesn't give me anything at all... How to printout the catching in VB.net?

gumuruh
  • 93
  • 4
  • 8

2 Answers2

2

In addition to Subhash's response, your application will only output to console if the console is available (i.e. in a Windows Console Application).

If you want to see those messages when debugging, see the following post which explains how to send the messages from Console.WriteLine to the Output window in VS (the same behaviour as using Debug.Print).

redirect console to visual studio debug output window in app.config

If you want to output the messages to a log, you can use a similar process to that explained in the link above. Simply change the writeline function to open a text file and write the message to the file.

Community
  • 1
  • 1
Smudge202
  • 4,689
  • 2
  • 26
  • 44
0

Is it a web app? If yes its better to write the exception in a log file. This way, you can view the log anytime you want in future.

Subhash Lama
  • 433
  • 2
  • 12