none
Why a datatable cannot be set to null value?

    Question

  • Hi,

     

    It is very strange that I cannot set a particular datatable object to null value.

     

    my code somehow doesn't work.

     

    Code Snippet

    dtRecord = null;

     

     

    I have this dtRecord in my ObjectA and there are few others object in ObjectA as properties. ObjectA was declared as static variable. I was able to set the rest to null and only this dtRecord somehow cannot.

     

    In debug mode,I tried to set the dtRecord in the debug window and it still shows {}, which is still not a null value. I've tried with other objects which have similar structure with ObjectA and it does works, it shows null.

     

    In what condition that this will happen? It is really drives me crazy.

     

    Regards,

    maxChin

    Tuesday, September 16, 2008 3:32 PM

Answers

  • Hi,

     

    Thanks for the reply.

     

    After trial and errors, I found out that in the same debug window, I have one statement to set datatable to null value and another statement to fill in datatable with data from database. That's why I always see the datatable filled in with data, shown as "{}" in the value column no matter how many time I set the datatable to null value. Every time I set datatable to null, the below statement then always followed and fill in the datatable with data again.

     

    Because of this, I thought that dtRecord = null; doesn't work even in debug mode. 

    Problem is resolved by now. Thank you very much.

     

     

    Regards,

    maxChin

    Thursday, September 18, 2008 3:53 PM

All replies

  • Hi

    can you provide code snippet completely? because of it's save time

    thank you
    Wednesday, September 17, 2008 2:13 AM
  • Hi,

     

    Thanks for the reply.

     

    After trial and errors, I found out that in the same debug window, I have one statement to set datatable to null value and another statement to fill in datatable with data from database. That's why I always see the datatable filled in with data, shown as "{}" in the value column no matter how many time I set the datatable to null value. Every time I set datatable to null, the below statement then always followed and fill in the datatable with data again.

     

    Because of this, I thought that dtRecord = null; doesn't work even in debug mode. 

    Problem is resolved by now. Thank you very much.

     

     

    Regards,

    maxChin

    Thursday, September 18, 2008 3:53 PM
  • Hi

    ya that why we asked  ode snippet, because of it's can set, but we need  know how to you are handling object, that why we asked code snippet. then it's would easy to help. thank you
    Friday, September 19, 2008 1:48 AM