马上就要论文答辩了,可是我的模糊查询的问题还没有。求助各位高手帮我看看!小弟在这里万分感谢!
Option Explicit
Dim panduan As String
Private Sub Command1_Click()
Dim rs_findbook As New ADODB.Recordset
Dim sql As String
If Check1.Value = vbChecked Then
sql = "编号='" & Trim(Text1.Text & " ") & "'"
sql = "select * from 论文信息 where " & sql
End If
If Check2.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "学生姓名='" & Trim(Text2.Text & " ") & "'"
Else
sql = sql & "and 学生姓名='" & Trim(Text2.Text & " ") & "'"
End If
sql = "Select * from 论文信息 Where [学生姓名] Like" + "'" + Text2 + "*" + "'"
DataGrid1.Refresh
End If
If Check3.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "所在班级='" & Trim(Text3.Text & " ") & "'"
Else
sql = sql & "and 所在班级='" & Trim(Text3.Text & " ") & "'"
End If
End If
If Check4.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "论文题目='" & Trim(Text4.Text & " ") & "'"
Else
sql = sql & "and 论文题目='" & Trim(Text4.Text & " ") & "'"
End If
End If
If Check5.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "论文成绩='" & Trim(Text5.Text & " ") & "'"
Else
sql = sql & "and 论文成绩='" & Trim(Text5.Text & " ") & "'"
End If
End If
If Check6.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "论文题目类型='" & Trim(Combo1.Text & " ") & "'"
Else
sql = sql & "and 论文题目类型='" & Trim(Combo1.Text & " ") & "'"
End If
End If
If Check7.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "指导教师='" & Trim(Text6.Text & " ") & "'"
Else
sql = sql & "and 指导教师='" & Trim(Text6.Text & " ") & "'"
End If
End If
If Check8.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "指导教师职称='" & Trim(Text7.Text & " ") & "'"
Else
sql = sql & "and 指导教师职称='" & Trim(Text7.Text & " ") & "'"
End If
End If
If Check9.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "评阅教师='" & Trim(Text8.Text & " ") & "'"
Else
sql = sql & "and 评阅教师='" & Trim(Text8.Text & " ") & "'"
End If
End If
If Check10.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "摘要 ='" & Trim(Text9.Text & " ") & "'"
Else
sql = sql & "and 摘要 ='" & Trim(Text9.Text & " ") & "'"
End If
End If
If Trim(sql) = "" Then
MsgBox "请选择查询方式!", vbOKOnly + vbExclamation
Exit Sub
End If
rs_findbook.CursorLocation = adUseClient
rs_findbook.Open sql, conn, adOpenKeyset, adLockPessimistic
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Dim rs As Recordset
Set DataGrid1.DataSource = rs_findbook
'rs_findbook.Close
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim rs_find As New ADODB.Recordset
Dim sql As String
sql = "select * from 论文类别"
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_find.MoveFirst
If Not rs_find.EOF Then
Do While Not rs_find.EOF
Combo1.AddItem rs_find.Fields(0)
rs_find.MoveNext
Loop
Combo1.ListIndex = 0
End If
rs_find.Close
End Sub