I don't see where have you used
SelectedNode
property.
Have a look at the details here:
TreeView.SelectedNode Property (System.Windows.Forms) | Microsoft Docs[
^]
Sample:
Private Sub myButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles myButton.Click
myTreeView.PathSeparator = "."
Dim myNodeCount As Integer = myTreeView.SelectedNode.GetNodeCount(True)
Dim myChildPercentage As Decimal = CDec(myNodeCount) / _
CDec(myTreeView.GetNodeCount(True)) * 100
MessageBox.Show(("The '" + myTreeView.SelectedNode.FullPath + "' node has " _
+ myNodeCount.ToString() + " child nodes." + Microsoft.VisualBasic.ControlChars.Lf _
+ "That is " + String.Format("{0:###.##}", myChildPercentage) _
+ "% of the total tree nodes in the tree view control."))
End Sub
Like above, once you know your selected node, use the way you seek (put in textbox as you shared)
Now, coming to a critical thing, your code is open for
SQL Injection. You should use
parametrized query
for accessing data. Read about it:
SQL Injection[
^]
Accessing data with ADO.NET[
^]
How to: Perform Parameterized Queries - SQL Server | Microsoft Docs[
^]