Je veux faire une condition pour mettre à jour ma table s'il y a déjà les mêmes données (dans la même colonne) insérées dans la table.comment faire condition pour mettre à jour la table?
im en utilisant
If String.ReferenceEquals(hotel, hotel) = False Then
insertDatabase()
Else
updateDatabase()
End If
c'est le code updateDatabase() ...
Dim sql2 As String = "update infoHotel set nameHotel = N" & FormatSqlParam(hotel) & _
", streetAddress = N" & FormatSqlParam(StreetAddress) & _
", locality = N" & FormatSqlParam(Locality) & _
", postalCode = N" & FormatSqlParam(PostalCode) & _
", country = N" & FormatSqlParam(Country) & _
", addressFull = N" & FormatSqlParam(address) & _
", tel = N" & FormatSqlParam(contact) & _
"where hotel = '" & hotel & "')"
c'est le code formatSqlParam():
Function FormatSqlParam(ByVal strParam As String) As String
Dim newParamFormat As String
If strParam = String.Empty Then
newParamFormat = "'" & "NA" & "'"
Else
newParamFormat = strParam.Trim()
newParamFormat = "'" & newParamFormat.Replace("'", "''") & "'"
End If
Return newParamFormat
End Function
la fonction parviennent à aller dans updateDatabase() mais a une erreur en disant
"Syntaxe incorrecte près de 'Oriental'."
Oriental est la donnée insérée dans le tableau. Est-il approprié d'utiliser ReferenceEquals?
im using vb.net et sql database..tq
1) Montrez-nous le code de 'updateDatabase()'. 2) Cette comparaison sera ** toujours ** "vraie". – egrunin