void Insert()
{
//the data
//Color
ParamColor SqlParameter = new SqlParameter();
paramColor.DbType = DbType.String;
paramColor.Direction = ParameterDirection.Input;
paramColor.ParameterName = "@Color";
paramColor.Value = item.Color;
command.Parameters.Add(paramColor);
command.CommandText = "insert into Inventory (Make, PetName, Color) values ('@MakeI', '@PetNameI', '@Color')";
result = command.ExecuteNonQuery() > 0 ? true : false;
}
Well, of course, the base will fly string constants - you do them and send. That's when you C# write the names of string variables in quotes did not take - why are you doing this in SQL language?insert into Inventory (Make, PetName, Color) values ('@MakeI', '@PetNameI', '@Color')"
Remove superfluous ternary operator, and you will be a Hindu!result = command.ExecuteNonQuery() > 0 ? true : false;
Find more questions by tags SQL Server.NETC#
That's right: result = command.ExecuteNonQuery() > 0 - Emiliano.Cremin commented on September 19th 19 at 00:02