I'm building a windows application that has a datagrid. I want to make a few columns invisible and have found a way to do it using a dataset. When I load the datagrid with a datatable, it works fine. However when I load it with a dataset I get the following error:
An unhandled exception of type 'System.ArgumentNullException' occurred in system.data.dll
Additional information: Value cannot be null.
All of the fields I'm loading into the grid have a value other than null.
So I guess my question is:
Does anyone know a way to make columns in a datagrid invisible using a datatable?
OR
Does anyone know what the difference is between the following code?
'Works -------------
Dim ad As SqlClient.SqlDataAdapter
Dim tab As New DataTable()
Dim ds As DataSet
OpenSQLConnection()
ad = New SqlClient.SqlDataAdapter("select TaskID, ProjectID, [Description], StartDate, DueDate, CompleteDate, Status, [Dependency] from Task where ProjectID = 1 order by [Order]", con)
ad.Fill(tab)
TaskGrid.DataSource = tab
CloseSQLConnection()
'Does not work -----
Dim ad As SqlClient.SqlDataAdapter
Dim tab As New DataTable()
Dim ds As DataSet
OpenSQLConnection()
ad = New SqlClient.SqlDataAdapter("select TaskID, ProjectID, [Description], StartDate, DueDate, CompleteDate, Status, [Dependency] from Task where ProjectID = 1 order by [Order]", con)
ad.Fill(ds, "Tasks"
TaskGrid.DataSource = ds.Tables("Tasks"
CloseSQLConnection()
An unhandled exception of type 'System.ArgumentNullException' occurred in system.data.dll
Additional information: Value cannot be null.
All of the fields I'm loading into the grid have a value other than null.
So I guess my question is:
Does anyone know a way to make columns in a datagrid invisible using a datatable?
OR
Does anyone know what the difference is between the following code?
'Works -------------
Dim ad As SqlClient.SqlDataAdapter
Dim tab As New DataTable()
Dim ds As DataSet
OpenSQLConnection()
ad = New SqlClient.SqlDataAdapter("select TaskID, ProjectID, [Description], StartDate, DueDate, CompleteDate, Status, [Dependency] from Task where ProjectID = 1 order by [Order]", con)
ad.Fill(tab)
TaskGrid.DataSource = tab
CloseSQLConnection()
'Does not work -----
Dim ad As SqlClient.SqlDataAdapter
Dim tab As New DataTable()
Dim ds As DataSet
OpenSQLConnection()
ad = New SqlClient.SqlDataAdapter("select TaskID, ProjectID, [Description], StartDate, DueDate, CompleteDate, Status, [Dependency] from Task where ProjectID = 1 order by [Order]", con)
ad.Fill(ds, "Tasks"
TaskGrid.DataSource = ds.Tables("Tasks"
CloseSQLConnection()