| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 455 人关注过本帖
标题:[求助!]怎样在我的这段程序中实现模糊查询
只看楼主 加入收藏
vivabaggio
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-6-6
收藏
 问题点数:0 回复次数:0 
[求助!]怎样在我的这段程序中实现模糊查询

马上就要论文答辩了,可是我的模糊查询的问题还没有。求助各位高手帮我看看!小弟在这里万分感谢!
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

搜索更多相关主题的帖子: 查询 模糊 
2006-06-06 12:18
快速回复:[求助!]怎样在我的这段程序中实现模糊查询
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016356 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved