value can not be null in datatable in 2005

Posted on 2007-08-02
Last Modified: 2013-11-26

I have the following code: -

SQL = "Select * from dbo.Locations"
        Dim da As New SqlClient.SqlDataAdapter(SQL, oConn)

        da.Fill(ds, "Locations")
        DataGridView1.DataSource = ds.Tables("Locations")

It always comes up with: -

Value cannot be null.
Parameter name: dataSet

What does this mean please and how to I resolve it.

Many Thanks
Question by:ljhodgett
    1 Comment
    LVL 53

    Accepted Solution

    The error message means that the dataset object you are passing is not instantiated.
    How are you instantiating the dataset object?
    Dim ds as Dataset.
    Dim ds as new dataset?
    I think if you make an instance of the dataset object, this problem should go away.

    SQL = "Select * from dbo.Locations"
            Dim da As New SqlClient.SqlDataAdapter(SQL, oConn)
            Dim ds as New DataSet
            da.Fill(ds, "Locations")
            DataGridView1.DataSource = ds.Tables("Locations")

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now