LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1505|回复: 1

如果大家还想看到我,请帮我看一下吧~~~~~~~简单的数据库问题,但。。。我快歇菜了

[复制链接]
发表于 2007-5-28 22:48:01 | 显示全部楼层 |阅读模式
[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
 楼主| 发表于 2007-5-29 04:21:13 | 显示全部楼层
搞定了!
不过还有一个疑问,在asp.net里面如何在一个TextBox里面实现选中即复制呢?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表