简单问题之这样写对不对
Dim strFilter As String
If TextBox1.Text.Trim.Length = 0 And TextBox2.Text.Trim.Length = 0 Then
strFilter = " "
Else
If TextBox1.Text.Trim.Length <> 0 Then
strFilter = "where 用户编号 = ' " + TextBox1.Text.Trim() + " ' "
If TextBox2.Text.Trim.Length <> 0 Then
strFilter += "and where 姓名 = ' " + TextBox2.Text.Trim() + " ' "
End If
End If
If TextBox1.Text.Trim.Length = 0 And TextBox2.Text.Trim.Length <> 0 Then
strFilter = "where 姓名 = ' " + TextBox2.Text.Trim() + " ' "
End If
End If
Dim strSQL As String = "select * from 人员表 " + strFilter
--------------------------------
[解决办法]
If TextBox1.Text.Trim.Length <> 0 Then
strFilter = "where 用户编号 = ' " + TextBox1.Text.Trim() + " ' "
If TextBox2.Text.Trim.Length <> 0 Then
strFilter += "and where 姓名 = ' " + TextBox2.Text.Trim() + " ' "
End If
End If
有两个Where了.
你Console.Write一下strSql看看是否合适.
[解决办法]
同意LS,2个where了。。。