|
[php]
'===========================单一关键词查询====================
Private Sub Single_Sch()
'清空列表
CheckTex1.Items.Clear()
CheckTex2.Items.Clear()
'记录查询模式为英文查中文还是中文查英文
Dim CheckMode,OtherMode As String
'查询语句
Dim sqlstr As String
'若查询信息为空则直接结束函数
If KeyTex1.Text = "" Then
Exit Sub
End If
'判断查询串是否为英文
If (Left(KeyTex1.Text,1)>="a" And Left(KeyTex1.Text,1)<="z") or (Left(KeyTex1.Text,1)>="A" And Left(KeyTex1.Text,1)<="Z") Then
CheckMode = "word"
OtherMode = "mean"
Else
CheckMode = "mean"
OtherMode = "word"
End If
'建立查询语句
sqlstr = "select distinct top 100 * from dic where " & CheckMode & " like '" & "%" & KeyTex1.Text & "%' order by " & CheckMode
'建立connection对象
Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=c:\inetpub\wwwroot\dictionary.mdb")
'建立command对象
Dim cmd As New OleDbCommand(sqlstr, conn)
'打开数据库连接
conn.Open()
'建立datareader对象
Dim dr As OleDbDataReader = cmd.ExecuteReader()
'读取查询结果
While dr.Read()
CheckTex1.Items.Add(dr.Item(CheckMode))
CheckTex2.Items.Add(dr.Item(OtherMode))
End While
dr.Close()
'==============匹配结果=============
'查询完全匹配的结果
sqlstr = "select distinct top 100 * from dic where " & CheckMode & " = '" & KeyTex1.Text & "'"
'建立command对象
Dim cmd1 As New OleDbCommand(sqlstr, conn)
'建立datareader对象
Dim dr1 As OleDbDataReader = cmd1.ExecuteReader()
'显示匹配结果
Result.text = "<center>查询结果</center><p>"
Result.text &= "<table border = '1'>"
result.text &= "<tr bgcolor = '#cdcdcd'>"
result.text &= "<td>"
result.text &= "<center> 英文 </center>"
result.text &= "</td>"
result.text &= "<td>"
result.text &= "<center> 中文 </center>"
result.text &= "</td>"
result.text &= "</tr>"
result.text &= "<tr bgcolor = '#cdcdcd'>"
result.text &= "<td>"
If dr1.Read() Then
Result.Text &= dr1.Item("word") & "</td><td>" & dr1.Item("mean")
Else
Result.Text &= "<center>无</center>" & "</td><td>" & "<center>无</center>"
End If
result.text &= "</td>"
result.text &= "</tr>"
result.text &="</table>"
'关闭数据库
conn.Close()
End Sub
[/php]
1.
'判断查询串是否为英文
If (Left(KeyTex1.Text,1)>="a" And Left(KeyTex1.Text,1)<="z") or (Left(KeyTex1.Text,1)>="A" And Left(KeyTex1.Text,1)<="Z") Then
CheckMode = "word"
OtherMode = "mean"
Else
CheckMode = "mean"
OtherMode = "word"
End If
这里CheckMode OtherMode是什么意思?
2.哪位对上面了解的数据库高人留个联系方式,最好是IM类,谢谢了,要不我真的再见不到大家了~~ 我qq: 2883358 |
|