Using of (<>) notequal operator in vb.net

Posted by Naeem2049 under VB.NET on 12/14/2011 | Points: 10 | Views : 22341 | Status : [Member] | Replies : 2
Hi All,

i have senario to display oracle database values in the web form ... so i have done this in c# but we need it in VB.Net i used code converter to convert aspx.cs code into vb.net..

but on if condition i used != operator in c# but in VB.Net it's gives error after converting..

The C# code line is::

while (dr.Read())
{
if (dr["EMPLOOYID"] != DBNull.Value)
{
TxtbxEmployee.Text = (string)dr["EMPLOOYID"];
}
}

The VB.Net code line is like this::

While dr.Read()

'If dr("IBANACCOUNT") <> DBNull.Value Then
' IbanAccountTextBox.Text = CType(dr("IBANACCOUNT"), String)
'End If

but in VB.net code line it gives code syntax error using <> operator

The error is :: Operator '<>' is not defined for type 'DBNull' and type 'Integer'.

main problem is i don't know how to use <> operator in the same line of code in the working condition..

please someone help me in this syntax error because in C# it's working fine ...

Thanks




Responses

Posted by: Hmanjarawala on: 12/14/2011 [Member] Bronze | Points: 25

Up
0
Down
write this:

If Not IsDBNull(dr("IBANACCOUNT")) Then
IbanAccountTextBox.Text = CType(dr("IBANACCOUNT"), String)
'End If


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Naeem2049, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naeem2049 on: 12/17/2011 [Member] Starter | Points: 25

Up
0
Down

Hi Himanshu Manjarawala,

Thanks for this kind help... this will solve my problem ... very very thanks

Regards
Naeem

Naeem2049, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response