请举例说明一下。怎么样的多条件,需要怎么样分页,最后得到什么结果
[此贴子已经被作者于2024/9/19 8:43:35编辑过]
我尝试用了LoadFilter,LoadOver这俩好像不能一块用
[此贴子已经被作者于2024/9/19 8:57:18编辑过]
Dim xingming As String
Dim shenfenzheng As String
Try
xingming = e.Values("xingming").ToString.Trim()
Catch ex As Exception
xingming = ""
End Try
Try
shenfenzheng = e.Values("shenfenzheng").ToString.Trim()
Catch ex As Exception
shenfenzheng = ""
End Try
cmd.CommandText = sql
Dim dt As DataTable = cmd.ExecuteReader
If shenfenzheng.Length <> 0 Then
dt.LoadFilter = " 基本信息.shenfenzheng = '" & shenfenzheng & "'"
End If
If xingming.Length <> 0 Then
dt.LoadFilter = " 基本信息.xingming like '%" & xingming & "%'"
End If
dt.LoadTop = e.Values("limit")
dt.LoadPage = e.Values("page") - 1
dt.LoadOver = "id"
dt.Load()
……
Dim sql As String = "select * from 基本信息 left join 台同信息 on 基本信息.gonghao = 合同信息.gonghao where 1=2"
……
Dim filter As String = "1=1 "
If e.Values.ContainsKey("shenfenzheng") Then
filter = filter & " and 基本信息.shenfenzheng = '" & shenfenzheng & "'"
End If
If e.Values.ContainsKey("xingming") Then
filter = filter & " and 基本信息.xingming like '%" & xingming & "%'"
End If
Dim limit As Integer = 10
If e.Values.ContainsKey("limit") Then
limit = e.Values("limit")
End If
Dim page As Integer = 0
If e.Values.ContainsKey("page") Then
page = e.Values("page")
If page > 0 Then
page = page - 1
End If
End If
cmd.CommandText = sql
Dim dt As DataTable = cmd.ExecuteReader
dt.LoadFilter = filter
dt.LoadTop = limit
dt.LoadPage = page
dt.LoadOver = "id"
dt.Load()