Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with integer conversion
Message
De
11/09/2013 18:51:21
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Problem with integer conversion
Versions des environnements
SQL Server:
SQL Server 6.5 and older
Application:
Web
Divers
Thread ID:
01582916
Message ID:
01582916
Vues:
51
Hi all -

I am really puzzling over this one. This code
oCommand.CommandText = "INSERT INTO [TIP_AmendmentApprovedFunding] (AmendmentNumber, TipID, Amount, Fundtype, Year, Phase) "
oCommand.CommandText += "SELECT @AmendmentNumber, TipID, Amount, Fundtype, Year, Phase "
oCommand.CommandText += "FROM [TIP_ApprovedFunding] WHERE (TipID = @TipID and year > @AmendmentNumber-1 and year < @AmendmentNumber+4)"
oCommand.ExecuteNonQuery()
has been working fine for months. Today all of a sudden it no longer works. With a value of 2014.05 for the @AmendmentNumber, it crashes with an error that says it can't convert the varchar value '2014.05' to an integer. Why it wants to convert it to an integer is beyond me. The field it's going into is a number(7,2) field.
So anyway, I thought I would help it along so I changed the code to this
oCommand.CommandText = "INSERT INTO [TIP_AmendmentApprovedFunding] (AmendmentNumber, TipID, Amount, Fundtype, Year, Phase) "
oCommand.CommandText += "SELECT @AmendmentNumber, TipID, Amount, Fundtype, Year, Phase "
oCommand.CommandText += "FROM [TIP_ApprovedFunding] WHERE (TipID = @TipID and year between convert(integer, @AmendmentNumber) and convert(integer, @AmendmentNumber + 4))"
oCommand.ExecuteNonQuery()
but it renders the same error. The parameter value is set like this
oCommand.Parameters.AddWithValue("@AmendmentNumber", Amendments_DDL.SelectedValue)
Any thoughts?
Thanks
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform