树状结构展示采购单Treeview 第三季

在第二季中,由于tiger_zhao 的回归,使剧情发生重大改变。下面贴出最新状况,希望这一季中能解决产品号Pcode为空时候引起的问题。
图片说明

在数据查询上面控制,如果为空,用其他值代替。。。解决了。。谢谢。

问题补充代码:
Public Class SampleInst
Dim mycn As New SqlClient.SqlConnection
Dim myadapter As New SqlClient.SqlDataAdapter
Private Sub SampleInst_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DateTimePicker1.Value = DateTime.Now.AddMonths(-1)
mycn.ConnectionString = "Data Source=127.0.0.1;Initial Catalog=blue;uid=sa;pwd=0000"
Dim mysql As String = " select samid,SamState,slState,(select procode from product(nolock) where Proid=Slproid) as Pcode,(select proName from product(nolock) where Proid=Slproid) as PName from Sample left join Samplelist on samid=slsamID and SamCdate between '" & DateTimePicker1.Value & "' and '" & DateTimePicker2.Value & "' and SamID like '%" & ComboBox1.Text & "%' order by samcdate desc,SamID desc,Pcode asc"
Dim mycom As New SqlClient.SqlCommand(mysql, mycn)
Dim dt As New DataTable
Try
mycn.Open()
myadapter.SelectCommand = mycom
myadapter.Fill(dt)
Dim nd1 As TreeNode = Nothing
For Each dr As DataRow In dt.Rows
If (nd1 Is Nothing) OrElse (nd1.Name <> dr(0)) Then
nd1 = Me.TreeView1.Nodes.Add(dr(0), Mid(dr(0), 1))
End If
If Not String.IsNullOrEmpty(dr(3)) Then
nd1.Nodes.Add(dr(3), dr(3))
End If
Next
Catch ex As Exception

    Finally
        mycn.Close()
    End Try
End Sub