以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]sqlfind问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=138181)

--  作者:晨曦396
--  发布时间:2019/7/24 16:57:00
--  [求助]sqlfind问题
Dim cmc As WinForm.CheckedComboBox
Dim c As String
Dim d As String
c= e.Form.Controls("ComboBox1").text
cmc = e.Form.Controls("CheckedComboBox1")
cmc.ComboList = DataTables("用户分组").SQLGetComboListString("分组")

Dim i As Integer = 0
For Index As Integer = 0 To cmc.Items.Count - 1
    Dim dr As DataRow = DataTables("用户分组").Find("分组 = \'" & cmc.Items(Index) & "\' And 用户 = \'" & c & "\'")       
    If dr IsNot Nothing Then
        i = i+1
        If i = 1 Then
            d= dr("分组")
        Else
            d= d & "," & dr("分组")
        End If
    End If
Next

e.Form.Controls("CheckedComboBox1").text = d

以上代码中 sql不能查询到数据,但是用find就能查到,(数据已经保存到后台数据库中) 

--  作者:有点蓝
--  发布时间:2019/7/24 17:02:00
--  
Dim cmc As WinForm.CheckedComboBox
Dim c As String
Dim d As String
c= e.Form.Controls("ComboBox1").text
cmc = e.Form.Controls("CheckedComboBox1")
cmc.ComboList = DataTables("用户分组").SQLGetComboListString("分组")
cmc.text = DataTables("用户分组").SQLGetComboListString("分组","用户 = \'" & c & "\'").replace("|",",")

--  作者:晨曦396
--  发布时间:2019/7/24 17:30:00
--  
Dim i As Integer = 0
For Index As Integer = 0 To cmc.Items.Count - 1
    Dim dr As DataRow = DataTables("用户分组").Find("分组 = \'" & cmc.Items(Index) & "\' And 用户 = \'" & c & "\'")       
    If dr IsNot Nothing Then

是这个位置的,我用sqlfind 查 dr 是nothing ,但是改成用find ,就有数据 ,确定已经保存到后台了
[此贴子已经被作者于2019/7/24 17:30:59编辑过]

--  作者:有点蓝
--  发布时间:2019/7/24 17:35:00
--  
代码没有问题。应该是数据的问题,到后台数据库看看用户列的类型是什么,数据是不是有很多空格?

另外没有必要在循环了,这样一句代码就够了
cmc.text = DataTables("用户分组").SQLGetComboListString("分组","用户 = \'" & c & "\'").replace("|",",")

--  作者:晨曦396
--  发布时间:2019/7/24 17:39:00
--  
好的谢谢