我现在在做图书馆管理系统,做图书查询的时候,我设计了用户可以通过多种方法查询,通过输入图书编号(Text1)、图书名称(Text3)、图书类别( DBCombo1)、出版社(DBCombo1)、作者姓名(Text2)、登记日期( DTPicker1)查询,可以同时输入两个以上查询信息,输完后按“查询”按扭就会在表中显示所查图书信息,表是用Adodc1来连接数据库的。可是运行时总是说from子句语法错误,各位高手,帮我找找程序错在哪里?我已经想了两天了还是没解决。谢谢各位了!“查询”按扭的代码是这样的: Dim sql As String Dim str(6) As String '保存设置的查询条件 Dim count As Integer '判断用户添写的条件的数目 Dim i As Integer count = 0
If Text1.Text <> "" Then str(1) = "图书编号='" & Text1.Text & "'" Else str(1) = "" End If If Text3.Text <> "" Then str(2) = "图书名称='" & Text3.Text & "'" Else str(2) = "" End If If DBCombo1.Text <> "" Then str(3) = "图书类别='" & DBCombo1.Text & "'" Else str(3) = "" End If If DBCombo2.Text <> "" Then str(4) = "出版社='" & DBCombo2.Text & "'" Else str(4) = "" End If If Text2.Text <> "" Then str(5) = "作者姓名='" & Text2.Text & "'" Else str(5) = "" End If If Check1.Value = 1 Then str(6) = "登记日期=#" & DTPicker1.Value & "#" Else str(6) = "" End If If str(1) = "" And str(2) = "" And str(3) = "" And str(4) = "" And str(5) = "" And str(6) = "" Then sql = "select * from 图书信息" Else sql = "select * from 图书信息 where" For i = 1 To 6 If str(i) <> "" Then count = count + 1 If count = 1 Then '第一个查询条件不需要"and"连接符 sql = sql + str(i) Else '以后的查询条件都需要"and"连接符 sql = sql + "and" + str(i) End If End If Next End If Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\book.db1.mdb;Persist Security Info=False" Adodc1.CursorLocation = adUseClient Adodc1.CommandType = adCmdText Adodc1.RecordSource = sql Adodc1.Refresh End Sub