I have a carsale project. It completely works on localhost. I have a "AddCar.aspx" page that inserts a car record with car's features. Car features are selected with checkboxes. If i don't check any checkbox, there is no problem. But if i check one of feature checkboxes, my page gives an error like this:
"Subqueries are not allowed in this context. Only scalar expressions are allowed."
And my code is like that:
foreach (DataListItem item in Security1.Items) {
CheckBox CheckBox1 = (CheckBox)item.FindControl("CheckBox1");
if (CheckBox1.Checked) {
HiddenField h = (HiddenField)item.FindControl("FeaID");
string add = "Insert into Carfeature (RecID,FeatureID) values ((select Max(RecID) from record),@FeatureID)";
cmd[k] = new SqlCommand();
cmd[k].CommandType = CommandType.Text;
cmd[k].Parameters.Add("@FeatureID", SqlDbType.Int).Value = h.Value;
cmd[k].CommandText = add;
k++;
}
}
Is there any solution?