Click here to Skip to main content
15,921,174 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! Guys..Can you help me in this error quoted "Conversion from string "applicationdate" to type 'Integer' is not valid."

this is the behind code:


Line 196: .Add("@Package", SqlDbType.VarChar, 500, "package")
Line 197: .Add("@PromoCode", SqlDbType.VarChar, 500, "promocode")
Line 198: .Add("@ApplicationDate", SqlDbType.DateTime, "applicationdate")
Line 199: .Add("@PaymentDate", SqlDbType.DateTime, "paymenttype")
Line 200: .Add("@EndorsedDate", SqlDbType.DateTime, "endorseddate")

very well appreciated with your comment

thanks in advance..
Posted

Its the same problem as here:

Input string was not in a correct format.[^]

Look at the two lines above it, notice the 500 thats missing? You need to supply that integer value on those ones too.
 
Share this answer
 
Comments
Member 10033107 5-Jun-13 21:44pm    
HI Ron..on declaring the application date how do i declare date like yr/month/date with also same command here cmd.Parameters("@date").Value = date??
Ron Beyer 5-Jun-13 21:49pm    
Yes, as long as date is a DateTime then the parameter will infer the type of the parameter when it creates it.
Member 10033107 5-Jun-13 21:53pm    
ok im wondering what do you mean in my statement of 500?? i believe that my size of the value for package and promocode also with other value i comment out.. do i need to remove it that's what i think on what you've said earlier
Ron Beyer 5-Jun-13 21:56pm    
No, what I'm saying is that there is no overload of the .Add function that takes (ParameterName, SqlDbType, ColumnName). Its trying to convert it because the closest overload is .Add(ParameterName, SqlDbType, int32). Its trying to convert your string to the int32 parameter. See the linked question in my answer for links to the MSDN documentation for the .Add function.
Ron Beyer 5-Jun-13 22:03pm    
BTW, this is a really horrible "feature" of VB.NET, implicit type conversion between unrelated types. In C# this would cause a very apparent compile-time error.
Putting the variable applicationdate in quotes like this "applicationdate" causes VB.NET to treat it like a string. If it's a variable, don't use quotes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900