none
Update null values in data set/ data table with default value ? RRS feed

  • Question

  • Update null values in  data set/ data table in with default value  ?

    In a single strke...

    Friday, March 26, 2010 6:05 AM

Answers

  • Ajay,

     

    There's no equivalent of an UPDATE query against a DataSet or DataTable that would affect multiple rows at once.  If the rows already exist, you'll need to use a loop.  You could combine it with a call to DataTable.Select to simplify your code.

     

    Another option is to set the DataColumn's DefaultValue property to the desired value prior to adding DataRows.

     

    I hope this information proves helpful.


    David Sceppa
    Wednesday, March 31, 2010 6:09 PM
    Moderator

All replies

  • It will be hard without a loop.
    Miha Markic [MVP C#] http://blog.rthand.com
    Friday, March 26, 2010 10:17 AM
  • Do you mind giving further explanation of  what you want to do?
    Only performance counts!
    Sunday, March 28, 2010 10:29 AM
  • I have data set with some column has Null value.

    I want update it with default value in single stament with out loop how to do that?

    Monday, March 29, 2010 9:00 AM
  • Ajay,

     

    There's no equivalent of an UPDATE query against a DataSet or DataTable that would affect multiple rows at once.  If the rows already exist, you'll need to use a loop.  You could combine it with a call to DataTable.Select to simplify your code.

     

    Another option is to set the DataColumn's DefaultValue property to the desired value prior to adding DataRows.

     

    I hope this information proves helpful.


    David Sceppa
    Wednesday, March 31, 2010 6:09 PM
    Moderator