Marcus
Marcus

Reputation: 5457

Insert/Update a cell to BLANK value into .xls using OleDB

I'm reading time values from an Excel spreadsheet displaying in a GridView. The user can update these values. When calling the OleDB UPDATE, I am passing in the format 3:00 PM.
If the user deletes a time from the GridView (essentially passing in "" to my update method) I'd like the Excel file to show a blank cell. However, I keep getting a Data type mismatch in criteria expression. error when trying to update the cell with "". It also throws an error when passing in null.

Everything I've found so far deals with reading blank values. What do I UPDATE/INSERT the cell with to have it show up as blank?

Upvotes: 1

Views: 1963

Answers (1)

Wendie
Wendie

Reputation: 84

Though this is old but i ran into this same issue and got it resolved using

myCommand.Parameters.Add(New OleDbParameter(i, DBNull.Value))

dbnull.value.

Upvotes: 2

Related Questions