0 Replies Latest reply on Sep 3, 2019 1:44 AM by GSun

    Conversion from type 'DBNull' to type 'String' is not valid!


      I am trying to populate a Listbox control with values from an Oracle database11g xe. But it raises this error every time:

      Conversion from type 'DBNull' to type 'String' is not valid! so I handled the nulls from the database level. The error stop popping up but the Listbox control still remain blank.

      I used following code:

      Dim G_conn As New OracleConnection(Form3.g_JUNODb) 
      Dim go_cmd As New OracleCommand
      .Connection = G_conn
      .CommandText = "select nvl(description,'desc'),nvl(qty,'0'), nvl(selling_price,'1'),nvl(Amount,'1') from RICHCUT.current_sale1"
      .CommandType = CommandType.Text 
      Dim G_dataReader As OracleDataReader = go_cmd.ExecuteReader()
      While G_dataReader.Read() ListBox1.Items.Add(CStr(G_dataReader.Item("description")).PadRight(32) + "   N" + CStr(G_dataReader.Item("selling_price")) + "   (" + CStr(G_dataReader.Item("qty")) + ")   N" + CStr(G_dataReader.Item("amount"))) 
      End While 

      I have used these lines before and the application is working well.

      Just copied the same application and this problem started to my greatest surprise!

      I did not even add the nvl bla bla bla to the original select statement that's working!

      I need urgent help please.

      Thanks in anticipation..