-- 作者:jyh7081
-- 发布时间:2018/4/1 12:48:00
-- [求助]外部数据源怎样修改代码
以前的帖子,“简拼模糊查询”:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=12145&skin=0
如果是外部sql数据源,在哪里指定外部数据源?
请老师帮助改一下,谢谢!
1、AfterLoad,这个加上了数据源名称
Tables("模糊查询_Table1").Fill("select 编号,姓名 ,部门,职务 fro m{员工} where
[_Identify] > 0","swptsql",True)
2、TextChanged,这个怎么改?
Dim t As Table =Tables("模糊查询_Table1") Dim py,Lm,Ts,
Bm,sql,Lb,sl As String Dim Ls As New List(Of Integer) Dim Lss As New
List(Of String) Static st As String
Dim drs As New List(of DataRow)
\'定义一个DataRow行的集合 Ts = "编号,姓名,部门,职务"
\'查询相关列 Bm = "员工" If st = e.sender.Text.ToUpper Then
Return Else st = e.sender.Text.ToUpper End If e.sender.Text
= st Sendkeys.Send("^{END}")
\'光标定于输入框最后
drs = DataTables(Bm).Select("姓名 >
\'\'") \'赋值drs=员工表--姓名列不为空的 DataRow行 If drs.count > 0
Then \'如drs行数>0,执行... If st
IsNot Nothing Then
\'如输入框内容不为空,执行... For Each Lm In
Ts.split(",") \'遍历查询相关列 For Each dr As
DataRow In drs \'遍历所有行 py =
GetPY(dr(Lm),True) \'赋值py = 查询行查询列的简拼 If
dr(Lm).IndexOf(st)> -1 OrElse py.IndexOf(st) > -1
Then
\'如查询行查询列内容(或简拼)包含输入框内容,执行... If
Ls.Contains(dr("_Identify")) = False Then \'如不包含则增加
ls.Add(dr("_Identify")) End If
If Lss.Contains(dr(Lm)) = False
Then Lss.Add(dr(Lm)) End
If End If
Next Next If Ls.count > 0 Then For Each
n As Integer In Ls sql+ = "," &
n
Next sql = "[_Identify] In(" & sql.Trim(",") &
")" \'包含主键[_Identify]内容 sql = "select "
& Ts & " fro m{" & Bm & "} where " & sql
\'合成SQL语句
t.Fill(sql,True)
\'生成SQL查询表 For Each sl In Lss lb+ = "|" &
sl Next e.sender.ComboList =
lb \'形成输入框列表
Else MessageBox.show("抱歉,数据库中没有您想查询的信息!" )
\'e.sender.value = "" e.sender.Select
Return End If End If End If
|