Conversion from type 'DBNull' to type 'String' is not valid! — oracle-tech

    Forum Stats

  • 3,716,134 Users
  • 2,242,961 Discussions


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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

GSun Member Posts: 67

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
go_cmd.Connection = G_conn
go_cmd.CommandText = "select nvl(description,'desc'),nvl(qty,'0'), nvl(selling_price,'1'),nvl(Amount,'1') from RICHCUT.current_sale1"
go_cmd.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..
Sign In or Register to comment.