Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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

GSunSep 2 2019

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) 
G_conn
.Open() 
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 
G_dataReader
.Dispose()
go_cmd
.Dispose()

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

Comments

Post Details

Added on Sep 2 2019
0 comments
309 views