locked
We are no longer allowed to use "= DBNull.Value" RRS feed

  • Question

  • User-1346274724 posted

    We are no longer allowed to use "= DBNull.Value"  in our code to indicate empyt values probally a good practice

     

    I need a work arounds for  a empty textbox and empty dropdown list  in VB

     

    thanks so much for all your great help in ths forum

     

     

    
    


    Tuesday, October 29, 2013 2:00 AM

Answers

  • User-1346274724 posted

    thank you so much!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 30, 2013 5:02 AM

All replies

  • User724169276 posted

    for textboxes you can use

    textbox1.text=string.empty;

    and for dropdowns you can use

    if(dropDownList.Items.Count > 0) 
    { // do something... }
     
    else
    { // its empty or not initialized }
    Tuesday, October 29, 2013 3:18 AM
  • User1508394307 posted

    Check this thread http://forums.asp.net/t/1383849.aspx

    string name = dr["name"] == DBNull.Value ? "1" : dr["name"].ToString();

    or

    if (! DBNull.Value.Equals(row[fieldName])) 
          return (string) row[fieldName] + " ";

    Tuesday, October 29, 2013 4:16 AM
  • User-1346274724 posted

    thank you so much!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 30, 2013 5:02 AM
  • User724169276 posted

    mark that post which gave you an answer ...no yours ..

    Wednesday, October 30, 2013 8:28 AM