CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2008
    Posts
    5

    Exclamation HELP!! VB to C# problem for you C# guru's

    .Net 1.1
    I have created a dll in VB. This dll sets may different properties I am only having trouble with the dataset property. The APPNVPS is initialized with the user Id and password and sets the values to be consumed by my apps.

    This is the code in Vb which works correctly
    APPNVPS is a dll call which returns a dataset

    Code:
    Dim newObject As New APPNVPS(USERID, PASSWORD)
            Dim dsValues As New DataSet
            Dim stValue As String
            dsValues = newObject.AppValues
            If dsValues.Tables(0).Rows.Count > 0 Then
                MessageBox.Show("There are " & dsValues.Tables(0).Rows.Count & " records")
            End If
    The Message box show that I have 16 record
    
    C# code
    DataSet ds = new DataSet();
    APPNVPS objApp = new APPNVPS(UserID,Password);
    ds = objApp.AppValues;
    MessageBox::Show ds.Tables[0].row.count;
    Gives me a runtime error <undefined value> null value
    I know that I am not fluent in C# but this can't be that difficult.
    Last edited by cjard; May 6th, 2008 at 11:56 AM.

  2. #2
    Join Date
    Aug 2005
    Posts
    198

    Re: HELP!! VB to C# problem for you C# guru's

    That last line would certainly not compile. You seem to be mixing some C++/CLI in there also (the double colon qualifier).

    The literal conversion is (via Instant C#):

    APPNVPS newObject = new APPNVPS(USERID, PASSWORD);
    DataSet dsValues = new DataSet();
    string stValue = null;
    dsValues = newObject.AppValues;
    if (dsValues.Tables[0].Rows.Count > 0)
    {
    MessageBox.Show("There are " + dsValues.Tables[0].Rows.Count + " records");
    }
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

  3. #3
    Join Date
    May 2008
    Posts
    5

    **UPDATE To Clarify my issue**

    DataSet ds = new DataSet();

    APPNVPS objApp = new APPNVPS(UserID,Password);

    'Returns property value
    string DS = objApp.DataSource;
    txtDataSource.Text = DS;

    'Returns property value
    txtVersion.Text = objApp.Version;

    'Assigned to dataset property value
    ds = objApp.Printers;

    int intCount ;
    ***intCount = ds.Tables[0].Rows.Count;
    txtPrintCount.Text = intCount.ToString();

    **I am getting An unhandled Exception 'System.NullReferenceException' **
    ds value is <undefined>

    Once again this Visual Basic code above works correctly calls the same dll
    Thanks

  4. #4
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: HELP!! VB to C# problem for you C# guru's

    would you please learn to use the formatting buttons? press EDIT, select the portion of your post that is code, and then press the button?

    similarly for bold, there's a bold button
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  5. #5
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: HELP!! VB to C# problem for you C# guru's

    ps; if you didnt already know, C# is case sensitive. If you want to code in C# effectively youre going to have to smarten up all your sloppy VBad Habits
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  6. #6
    Join Date
    May 2008
    Posts
    5

    Re: HELP!! VB to C# problem for you C# guru's

    Nice, very insightfull. Thanks

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