I dont know if this thread is in the right forum, but here goes.
I have a Treeview (yes same problem I have addressed recently with ABODB databindings) and I can bind it to a Access database no problems. But in my infinite wisdom and learning vb.net I never really saw the need for SQL until recently... One it makes things more safer and the code is cleaner...
*clears head*
Back to my problem... I have a treeview I want to bind to a field in a SQL Server DB. the code I am using to "TRY" achieve this is as follows
Private Sub BindToTreeSQL()
Dim trvClient As TreeView
Dim varTvItem As TreeNode
Dim varDsRow As DataRow
trvClients.Nodes.Clear()
For Each varDsRow In SqlDsClients.Tables("ClientName").Rows
varTvItem = New TreeNode
With varTvItem
.Text = varDsRow.Item("ClientName")
End With
trvClients.Nodes.Add(varTvItem)
Next
End Sub
I have placed a call in my form load statement calling this sub. and I get an error :
An unhandled exception of type System.NullReferenceException occurred in Time Tracker.exe
Additional information: Object reference not set to an instance of an object.
Can anyone help me either fixing the problem? Or showing me how to bind a treeview to a SQL Database table and field.
Thanx a million
I have a Treeview (yes same problem I have addressed recently with ABODB databindings) and I can bind it to a Access database no problems. But in my infinite wisdom and learning vb.net I never really saw the need for SQL until recently... One it makes things more safer and the code is cleaner...
*clears head*
Back to my problem... I have a treeview I want to bind to a field in a SQL Server DB. the code I am using to "TRY" achieve this is as follows
Private Sub BindToTreeSQL()
Dim trvClient As TreeView
Dim varTvItem As TreeNode
Dim varDsRow As DataRow
trvClients.Nodes.Clear()
For Each varDsRow In SqlDsClients.Tables("ClientName").Rows
varTvItem = New TreeNode
With varTvItem
.Text = varDsRow.Item("ClientName")
End With
trvClients.Nodes.Add(varTvItem)
Next
End Sub
I have placed a call in my form load statement calling this sub. and I get an error :
An unhandled exception of type System.NullReferenceException occurred in Time Tracker.exe
Additional information: Object reference not set to an instance of an object.
Can anyone help me either fixing the problem? Or showing me how to bind a treeview to a SQL Database table and field.
Thanx a million