蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

.NET搜索问题!!!!!!!

这里search.aspx,里面有一个表单,一个textbox(id=key)和dropdownlist(id=Search_Type)控件和一个图片按钮(id=Go),search.aspx代码是这么写的:
Private Sub Go_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Go.Click
        Response.Redirect("search_list.aspx?search_type=" + Search_Type.SelectedItem.Value + "")
    End Sub

然后点击搜索,search_list.aspx代码是这么写的
Dim key, search_type, product_name, product_code, product_price As String
        key = Request.QueryString("Key")
        search_type = Request.QueryString("Search_Type")
        product_name = Request.QueryString("product_name")
        product_code = Request.QueryString("product_code")
        product_price = Request.QueryString("product_price")
        Dim DS As DataSet
        Dim MyConnection As New OleDbConnection
        Dim MyCommand As New OleDbDataAdapter
        MyConnection = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("../total_data/xxx.mdb"))
        Select Case search_type
            Case "product_name"
                MyCommand = New OleDbDataAdapter("select * from group_product where product_name like '%" & key & "%'", MyConnection)
            Case "product_code"
                MyCommand = New OleDbDataAdapter("select * from group_product where product_code like '%" & key & "%'", MyConnection)
            Case "product_price"
                MyCommand = New OleDbDataAdapter("select * from group_product where product_price like '%" & key & "%'", MyConnection)
        End Select
        'Response.Write(MyCommand)
        DS = New DataSet
        MyCommand.Fill(DS, "group_product")
        Product_DataList.DataSource = DS.Tables("group_product").DefaultView
        Product_DataList.DataBind()
        MyConnection.Close()

提交后搜索出来的是全部记录,不知道什么地方出错了,难道key这个值没有取到?

"search_list.aspx?search_type=" + Search_Type.SelectedItem.Value + ""
你看看,你只传了个search_type过去,其他的都没有传,哪里来的
product_name = Request.QueryString("product_name"
product_code = Request.QueryString("product_code"
product_price

??

明白了,谢谢,keyword这个值没传过去




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com