CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Posts
    596

    Some code a converter did that I don't understand.

    Hello everyone. I ran some vb code in an online vb to c# converter app and some of the code that it generated I can't get it to work. I get a red squiggly line under the word "Information" and the message is "The name "Information" does not exist in the current context. So I get rid of the word "Information". So now IsDBNull is underlined with the red squiggly line and the message now reads "The name 'IsDBNull' does not exist in the current context". This code is in a class source file which is part of a class library vs2008. Anyone able to give me a hand with this?

    Code:
     myPopulationGroupsTb = new PopulationGroupsTb();
    
                        var _with2 = myPopulationGroupsTb;
                        _with2.ID = (Information.IsDBNull(myReader["ID"]) ? 0 : myReader["ID"]);
                        _with2.PopulationGroup = (Information.IsDBNull(myReader["PopulationGroup"]) ? string.Empty : myReader["PopulationGroup"]);
                        _with2.PopulationGroupLabel = (Information.IsDBNull(myReader["PopulationGroupLabel"]) ? string.Empty : myReader["PopulationGroupLabel"]);
                        _with2.MinPopulation = (Information.IsDBNull(myReader["MinPopulation"]) ? 0 : myReader["MinPopulation"]);
                        _with2.MaxPopulation = (Information.IsDBNull(myReader["MaxPopulation"]) ? 0 : myReader["MaxPopulation"]);

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Some code a converter did that I don't understand.

    That converter produces code with horrible naming conventions. If the reader is a SqlDataReader, then just use its IsDbNull method.

  3. #3
    Join Date
    Aug 2005
    Posts
    198

    Re: Some code a converter did that I don't understand.

    The converter should have changed "Information.IsDBNull" to "System.Convert.IsDBNull".
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured