Input string was not in a correct format

  • Thread starter Thread starter William
  • Start date Start date
W

William

I am trying to update a backend Access DB once a user make a change in the
datagrid as follows:

private void dgrdResource_CurrentCellChanged(object sender,
System.EventArgs e)
{
int curColumn = dgrdResource.CurrentCell.ColumnNumber;
int curRowIndex = dgrdResource.CurrentCell.RowNumber;
string columnName = dtResources.Columns[curColumn].ColumnName;
string newValue = dgrdResource.CurrentCell.ToString();
daResources.UpdateCommand.Parameters["newValue"].Value = newValue;
DataRow curRow = dtResources.Rows[curRowIndex];
daResources.UpdateCommand.Parameters["LastName"].Value = curRow["LastName"].ToString();
daResources.UpdateCommand.Parameters["FirstName"].Value = curRow["FirstName"].ToString();

daResources.UpdateCommand.CommandText = String.Concat( "UPDATE Forecast SET ", columnName, " = ?", " WHERE LastName = ? AND FirstName = ?");
daResources.Update( dtResources );
}

and I got the error:
Input string was not in a correct format


any suggestions?
 
William said:
and I got the error:
Input string was not in a correct format

This most commonly means that you are trying to convert a string to a number, and it contains non
numeric data.
 
Back
Top