If I have this variable:
int value = 4;
which is to be passed as some sql parameter:
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Parameters.Add(new SqlParameter("@value", value));
Will it be converted to string and handled automatically? or could it possibly cause some trouble? ie. when I do this:
sqlcmd.ExecuteNonQuery();
Always provide the correct type, especially
int
is dangerous.From MSDN:
So if you want to use a string parameter, convert it to the correct type:
or
or (with the type)