以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]知道数值,不知道数据表,不知字段名,如何查找  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=125993)

--  作者:2900819580
--  发布时间:2018/10/11 16:18:00
--  [求助]知道数值,不知道数据表,不知字段名,如何查找
知道数值,不知道数据表,不知字段名,如何查找出数据表名称和字段名称

这样能做到吗?主要是想了解一下金碟的字段信息?

如知道料号 “7.05” 如何知道 那个数据中有这个数据
[此贴子已经被作者于2018/10/11 16:18:42编辑过]

--  作者:有点甜
--  发布时间:2018/10/11 16:24:00
--  

查询全部表全部列,查找

 

For Each t As Table In Tables
    For Each c As Col In t.Cols
        Dim i = t.FindRow("convert(" & c.name & ",\'System.String\')" & " = \'7.05\'")
        If i >= 0 Then
            msgbox(t.name & " " & i & " " & c.name)
        End If
    Next
Next


--  作者:2900819580
--  发布时间:2018/10/11 16:54:00
--  
老师,是外部SQL数据库来的,代码这样修改后会出错。
无法在 System.Int32 和 System.String 上执行“=”操作。

Dim lst As List(Of String)
lst = Connections("AIS20170303202558").GetTableNames
Dim cmd As New SQLCommand
cmd.C
For Each ls As String In lst
    cmd.CommandText = "Se lect * From {" & ls & "} "
    
    Dim dto As DataTable = cmd.ExecuteReader
    e.Form.Controls("TextBox2").text &= ls & "|" \'& c.Name    
    For Each c As DataCol In dto.DataCols
     
        Dim DR As DataRow = dto.Find(c.name & " = \'7.05\'"      )
        If dr IsNot Nothing Then
            msgbox(dto.name & " | " & c.name)
        End If
    Next
Next

--  作者:有点甜
--  发布时间:2018/10/11 17:02:00
--  

Dim DR As DataRow = dto.Find(c.name & " = \'7.05\'"      )

 

改成

 

Dim DR As DataRow = dto.Find("convert(" & c.name & ",\'System.String\') = \'7.05\'")