Input string was not in a correct format

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

Chad Z. Hower aka Kudzu

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top