以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  这段有语法错误,不知道错哪了  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=88316)

--  作者:天蝉一线
--  发布时间:2016/7/31 17:59:00
--  这段有语法错误,不知道错哪了
Dim cmd As New SQLCommand
cmd.Connectio n N ame="cwgl"
Dim dt As DataTable
cmd.CommandText = "SELECT * Fro m {会计科目}"
dt = cmd.ExecuteReader()
If dt.DataRows.Count>0 Then
    Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
    If trv.SelectedNode IsNot Nothing
        Dim Result As DialogResult
        Result = MessageBox.Show("您真的要删除这个会计科目吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Result = DialogResult.Yes Then
            cmd.CommandText = "delete for m {会计科目} where 科目编码 =trv.SelectedNode"
            cmd.ExecuteNo n Query()
            trv.SelectedNode.Delete
        End If
    Else
        Messagebox.show("对不起,没有数据,无法删除!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Return
    End If
End If

--  作者:大红袍
--  发布时间:2016/7/31 18:09:00
--  

cmd.CommandText = "delete for m {会计科目} where 科目编码 =trv.SelectedNode"

 

改成

 

cmd.CommandText = "delete for m {会计科目} where 科目编码 = \'" & trv.SelectedNode.FullName & "\'"

[此贴子已经被作者于2016/7/31 18:49:39编辑过]

--  作者:大红袍
--  发布时间:2016/7/31 18:11:00
--  

Dim cmd As New SQLCommand
cmd.ConnectionName="cwgl"

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
If trv.SelectedNode IsNot Nothing
    Dim Result As DialogResult
    Result = MessageBox.Show("您真的要删除这个会计科目吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
        cmd.CommandText = "delete for m {会计科目} where 科目编码 = \'" & trv.SelectedNode & "\'"
        cmd.ExecuteNonQuery()
        trv.SelectedNode.Delete
    End If
Else
    Messagebox.show("对不起,没有数据,无法删除!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If

[此贴子已经被作者于2016/7/31 18:10:58编辑过]

--  作者:天蝉一线
--  发布时间:2016/7/31 18:29:00
--  
编译错误:没有为类型“ string 和 winfrom.treenode定义运算符“&”
--  作者:大红袍
--  发布时间:2016/7/31 18:49:00
--  
 

Dim cmd As New SQLCommand
cmd.ConnectionName="cwgl"

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
If trv.SelectedNode IsNot Nothing
    Dim Result As DialogResult
    Result = MessageBox.Show("您真的要删除这个会计科目吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
        cmd.CommandText = "delete for m {会计科目} where 科目编码 = \'" & trv.SelectedNode.Text & "\'"
        cmd.ExecuteNonQuery()
        trv.SelectedNode.Delete
    End If
Else
    Messagebox.show("对不起,没有数据,无法删除!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If


--  作者:大红袍
--  发布时间:2016/7/31 18:50:00
--  
 你目录树是怎样的啊?科目编码又是怎样的啊?
--  作者:天蝉一线
--  发布时间:2016/7/31 19:01:00
--  
会计科目附近有语法错误
--  作者:天蝉一线
--  发布时间:2016/7/31 19:22:00
--  
目录树是以科目名称按照科目编码(比如214,21401)列示


--  作者:天蝉一线
--  发布时间:2016/7/31 19:35:00
--  
找到原因了,已解决