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?
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?