Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am attempting to use an update statement and oledb to write to my file but am having an issue passing empty values in the where clause of the update statement. The where clause is based on values from the file I am reading and some of them are blank sometimes.

How can I set values in my update statement's where clause that are essentially blank that excel will recognize as being empty? Please let me know if any clarification is needed or if this is even possible at all.

I have tried just using '' as the value if the cell being read is empty, but it does not work.

Thank you for any advice or suggestions.
Posted
Updated 26-Dec-12 6:38am
v4
Comments
Herman<T>.Instance 28-Dec-12 8:44am    
which component/interop do you use for your xlsx?
Richard C Bishop 7-Jan-13 9:53am    
I am using OleDb.

If you are using OLEDB, you can use DBNull.Value. This will insert null value into a table.
 
Share this answer
 
Comments
Richard C Bishop 7-Jan-13 9:56am    
It inserts a null value into a table, but does it do the same inserting into an Excel cell?
I ended up taking a different approach to solve this issue. Instead of writing back to the .xlsx file I was initially reading from, I have written the same content I was expecting to a .csv file.

It gives me the same functionality without having to worry about datatypes in Excel.
 
Share this answer
 
As the above answer suggests, you DBNull.Value.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900