• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

value can not be null in datatable in vb.net 2005

Hi,

I have the following code: -

SQL = "Select * from dbo.Locations"
        dbOpen()
        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
Lee
0
ljhodgett
Asked:
ljhodgett
1 Solution
 
DhaestCommented:
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.
or
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"
        dbOpen()
        Dim da As New SqlClient.SqlDataAdapter(SQL, oConn)
        Dim ds as New DataSet
        da.Fill(ds, "Locations")
        DataGridView1.DataSource = ds.Tables("Locations")
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now