With DataTables("商品")
Dim xiangz As RibbonMenu.TextBox = RibbonTabs("主信息").Groups("查询").Items("乡镇")
Dim cunm As RibbonMenu.TextBox = RibbonTabs("主信息").Groups("查询").Items("村")
Dim xingm As RibbonMenu.TextBox = RibbonTabs("主信息").Groups("查询").Items("姓名")
Dim xiaob As RibbonMenu.TextBox = RibbonTabs("主信息").Groups("查询").Items("货号")
If xiaob.text <> "" Then
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText ="Select Count(*) From {商品} Where [SYQQLR] Like '%" & xiangz.text & cunm.text & "%' and [DANWEI] Like '%" & xingm.text & "' and [XIAOBAN] = '" & xiaob.text & "'"
If cmd.ExecuteScalar > 0 Then
DataTables("商品").LoadFilter = "[SYQQLR] Like '%" & xiangz.text & cunm.text & "%' and [DANWEI] Like '%" & xingm.text & "' and [XIAOBAN] = '" & xiaob.text & "'"
DataTables("商品").Load
Else
MessageBox.Show("数据不存在")
End If
Else
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText ="Select Count(*) From {商品} Where [SYQQLR] Like '%" & xiangz.text & cunm.text & "%' and [DANWEI] Like '%" & xingm.text & "'"
If cmd.ExecuteScalar > 0 Then
DataTables("商品").LoadFilter = "[SYQQLR] Like '%" & xiangz.text & cunm.text & "%' and [DANWEI] Like '%" & xingm.text & "'"
DataTables("商品").Load
Else
MessageBox.Show("数据不存在")
End If
End If
End With
这段代码执行后经常报超时,多查几次又能查出来,但是要很长时间,求大能给我优化下