Take the 2-minute tour ×

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

        Dim oCommand As MySqlCommand = New MySqlCommand("SELECT * FROM suppliermst WHERE supplierid = " & p_iSupplierId, oConnection)
        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)

    End Try

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

share|improve this question
try ex.Message.ToString() instead –  Akshinthala సాయి కళ్యాణ్ Apr 20 '11 at 9:10
Is it a web app? –  Subhash Lama Apr 20 '11 at 9:11
@kalyan Exception.Message is a string already. ToString is inherited from object. –  Smudge202 Apr 20 '11 at 9:23
add comment

2 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer


