I have two radio boxes. One true, the other false. I have a flag set up, but it didn't work. Here is my code right now
string sqlStatement;
SqlConnection cnn = new SqlConnection(Properties.Settings.Default.cnnString);
cnn.Open();
SqlCommand cmd = cnn.CreateCommand();
cmd.CommandType = CommandType.Text;
sqlStatement = string.Format("UPDATE Results SET Finish = '{0}', Place = '{1}', FinishTime = {2}, Winnings = '{3}' Where ResultsId = '{4}' " + (rdoDidFinish.Checked ? 1 : 0), txtPlace.Text, txtTime.Text, txtWinnings.Text);
cmd.CommandText = sqlStatement;
cmd.ExecuteNonQuery();
cnn.Close();
The error I am getting is:
"Index (zero based) must be greater than or equal to zero and less than the size of the argument list."
String.Format()
call but are only passing 3 arguments. Also, as pointed out, you should really be using parameters rather than building your SQL statement like that as you're leaving yourself open to SQL Injection attacks.string.format
error. You have five parameters, but only provide 3 in your statement.