i want to make condition statement but unsuccessful
hi i want to make condition statement in my function. i use this method :
If St开发者_Go百科ring.ReferenceEquals(hotel, hotel) = true Then
insertDatabase()
Else
updateDatabase()
End If
if i try to insert a data already in the database, the function will directly go to the updateDatabase()..
the problem is, if i try to insert the data that currently not in the database, the function will directly go to update database as well..
maybe the method i use is not suitable. can anyone help?..im using vb.net and sql..
Some issues:
String.ReferenceEquals
will only return true for the same string object, not the same string value - not a good idea. The =
operator is suitable overridden in the String
class to allow you to just use that.
There's no point adding an = true
for a Boolean function.
So change your first line to something like:
If hotel1 = hotel2 Then
精彩评论