I'm having a strange issue with entering data into a SQL Server 2008 database, the error tells me that
System.Data.SqlClient.SqlException was unhandled HResult=-2146232060 Message=The variable name '@comments' has already been declared. Variable names must be unique within a query batch or stored procedure. Must declare the scalar variable "@employeeId".
Problem is... I did declare both of them, am I missing something?
public bool Addfix(DateTime receiveDate, int clientId, int modelID, string problem, string comment, int employeeId, float priceOffer, float price)
{
_cmd.CommandText ="INSERT INTO fixes(receiveDate, clientId, modelID, problem, comments, employeeId, priceOffer, price, returned) VALUES (@receiveDate, @clientId, @modelID, @problem, @comments, @employeeId, @priceOffer,@price,@returned);";
_cmd.Parameters.Add("@receiveDate", SqlDbType.Date).Value = receiveDate;
_cmd.Parameters.AddWithValue("@clientId", clientId);
_cmd.Parameters.AddWithValue("@modelID", modelID);
_cmd.Parameters.AddWithValue("@problem", problem);
_cmd.Parameters.AddWithValue("@comments", comment);
_cmd.Parameters.AddWithValue("@employeeId", employeeId);
_cmd.Parameters.AddWithValue("@priceOffer", priceOffer);
_cmd.Parameters.AddWithValue("@price", price);
_cmd.Parameters.AddWithValue("@returned ", 0);
_con.Open();
_cmd.ExecuteNonQuery();
_con.Close();
return true;
}