老师, 通过addnew添加的数据能否保存到数据库中 ?
为什么 Datatable ("表A") . load 之后添加的数据就没了呢 ?
If e.node.Checked Then
Dim r As Row = t.AddNew
r("所属团队") = "公司"
r("Name") = na
r("父键") = e.Node.ParentNode.Text
r("控件名称") = e.Node.Text
r("控件标题") = mc.DataRows(0)("控件标题")
r("不可用") = True
r("控件类型") = mc.DataRows(0)("类型")
r.Save()
For Each nd As WinForm.TreeNode In e.node.AllNodes '同步子节点选中状态
If nd.FullPath.StartsWith(e.node.FullPath) Then
cmd.CommandText = "sele ct * from 系统控件 where 控件名称 = '" & nd.Name & "' and 父键 = '" & nd.ParentNode.name & "' "
mc = cmd.ExecuteReader
Dim r2 As Row = t.AddNew
r2("所属团队") = "公司"
r2("Name") = na
r2("父键") = nd.ParentNode.Text
r2("控件名称") = nd.Text
r2("控件标题") = mc.DataRows(0)("控件标题")
r2("不可用") = True
r2("控件类型") = mc.DataRows(0)("类型")
r2.Save()
End If
Next
Else
t.DataTable.deletefor(" Name ='" & na & "' and 父键 = '" & mc.DataRows(0)("父键") & "' and 控件名称 = '" & e.node.text & "' and 不可用 = 1 ")
pd = e.node.ParentNode '获取父节点
Do While pd IsNot Nothing
t.DataTable.deletefor(" Name ='" & na & "' and 控件名称 = '" & pd.text & "' and 不可用 = 1 ")
pd = pd.ParentNode '继续获取上一层级的父节点
Loop
End If
t.DataTable.Load()