Click here to Skip to main content
12,354,998 members (62,812 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# MS-Excel
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 26-Dec-12 6:32am
Edited 26-Dec-12 6:38am
v4
Comments
digimanus 28-Dec-12 8:44am
   
which component/interop do you use for your xlsx?
richcb 7-Jan-13 9:53am
   
I am using OleDb.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

If you are using OLEDB, you can use DBNull.Value. This will insert null value into a table.
  Permalink  
Comments
richcb 7-Jan-13 9:56am
   
It inserts a null value into a table, but does it do the same inserting into an Excel cell?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

As the above answer suggests, you DBNull.Value.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160621.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100