Note that there are some explanatory texts on larger screens.

plurals
  1. POSystem.Exception: Incorrect syntax I can't find the problem
    text
    copied!<p>So I have a grid view with checkboxes in it. This is the code behind the page.</p> <pre><code>protected void BtnApproveUsers_Click(object sender, EventArgs e) { var num = new List&lt;int&gt;(); try { for (var i = 0; i&lt; GvApproveUser.Rows.Count; i++) { var row = GvApproveUser.Rows[i]; var isChecked = ((CheckBox) row.FindControl("ChbSelect")).Checked; if (isChecked) { num.Add(System.Convert.ToInt32(GvApproveUser.Rows[i].Cells[1].Text)); Authentication.ApproveUser(num, GvApproveUser.Rows.Count); } } throw new Exception("The registration forms were approved."); } catch (Exception exception) { throw new Exception(exception.Message); } } </code></pre> <p>And this is the method.</p> <pre><code>public static void ApproveUser(List&lt;int&gt; userIds, int rowCount) { using (var connection = Utils.Database.GetConnection()) try { for (var i = 0; i &lt; rowCount; i++) { using (var command = new SqlCommand("UPGRADE [Users] SET [Role] = @role WHERE [UserID] = @userId", connection)) { command.Parameters.AddWithValue("@role", "User"); command.Parameters.AddWithValue("@userId", userIds[i]); command.ExecuteNonQuery(); } } } catch (Exception exception) { throw new Exception(exception.Message); } } </code></pre> <p>And this is the exception:</p> <p>Incorrect syntax near 'Role'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <p>Exception Details: System.Exception: Incorrect syntax near 'Role'.</p> <p>Source Error: </p> <p>Line 52: { Line 53:<br> Line 54: throw new Exception(exception.Message); Line 55: } Line 56: </p> <p>I can't find the problem. Pls help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload