Results 1 to 3 of 3

Thread: VB.NET Newbie Need Help

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    5

    VB.NET Newbie Need Help

    Hello,

    I am trying to calculate the sum of the columns and I keep getting the same error: "Object reference not set to an instance of an object." My code is listed below.


    Dim ds As DataSet

    Dim myTable As DataTable

    'myTable = ds.Tables("Order Details")

    ' Declare an object variable.

    'Dim objSum As Object

    'objSum = ds.Tables("Order Details").Compute("Sum(UnitPrice)", "")

    'lblTotalCost.Text = objSum

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,443

    Re: VB.NET Newbie Need Help

    You haven't created a DataSet object. This:
    VB Code:
    1. Dim ds As DataSet
    declares a variable that can refer to a DataSet object but it does not create a DataSet object. You need to invoke the constructor with the New keyword:
    VB Code:
    1. Dim ds As New DataSet
    I suggest that you follow the Start VB.NET tutorial link in my signature and read at least the OOP section.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    5

    Re: VB.NET Newbie Need Help

    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