帮忙检查一下VB程序错误

来源:百度知道 编辑:UC知道 时间:2024/07/03 14:26:01
以下是我编写的程序,目的是实现多条件查询,那位大侠帮忙看看错在哪里,好像是au_info这个SQL语句有问题,解决问题之后必有重谢!!

Private Sub Command2_Click()

If Text1(1).Text = "" And Text1(2).Text = "" And Text1(3).Text = "" And Text1(4).Text = "" And Text1(5).Text = "" And Text1(6).Text = "" And Text1(7).Text = "" And Text1(8).Text = "" And Text1(0).Text = "" Then
int1 = MsgBox("您还没有输入查询条件", vbExclamation, "Warning")
Else
Dim au_info As String
Dim s(9) As String
s(0) = "au_id"
s(1) = "au_lname"
s(2) = "au_fname"
s(3) = "phone"
s(4) = "address"
s(5) = "city"
s(6) = "state"
s(7) = "zip"
s(8) = "contract"
au_info = "select * form authors where "
For i = 0 To 8
If Text1(i).Text <> "" Then
au_info = au_info & "&

If Text1(i).Text <> "" Then
au_info = au_info & "" + s(i) + "='" + Text1(i).Text + "' and"
End If
Next i
这一句错误,au_info 初值为 "select * form authors where "

在循环中使用 au_info = au_info &
导致结果为:
select * form authors where au_id = 1 and select * form authors where au_lname = ...