I'm trying to call a parameterized stored procedure from SQL Server 2005 in my C# Winforms app. I add the parameters from TextBoxeslike so (there are 88 of them):
cmd.Parameters.Add("@CustomerName", SqlDbType.VarChar, 100).Value = CustomerName.Text;
I get the following exception:
"System.InvalidCastException: Failed to convert parameter value
from a TextBox to a String. ---> System.InvalidCastException:
Object must implement IConvertible."
The line throwing the error is when I call the query:
cmd.ExecuteNonQuery();
I also tried using the .ToString() method on the TextBoxes, which seemed pointless anyway, and threw the same error. Am I passing the parameters incorrectly?