从前端搜索数据库或多个条件... [英] Search database or multiple criteria from front end...

查看:99
本文介绍了从前端搜索数据库或多个条件...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我想根据用户填写的多个条件来搜索我的数据库",但仍无法做到这一点.城市名称,位置名称属性类型应相同,但价格和面积应在用户指定的范围内用户...请帮助,谢谢....

表格设计

Sir i want to search My Databse based on multiple criteria fill by the user but m not getting how to do that..city name,locality name property type should be same but price and area should be within the range specified by the user...pls help thanks in advance....

Form Design

<div>

           <table cellspacing="15" style="width:80%">
               <tr>
                   <td colspan="2" align="left">
                       <span style="font-size: small; font-family: Arial">Fields marked with
                   </span>
                   <span style="color: #FF3300; font-size: small; font-family: Arial;">*</span><span
                           style="font-size: small; font-family: Arial"> are
                   mandatory:

                   </span>

                   </td>
               </tr>
               <tr>
                   <td colspan="2" align="left">
                       <span style="text-decoration:none">
                       <span style="text-decoration: underline">Search Property For:</span></span><br /><br />
                       <asp:RadioButton ID="rbtnfs" Checked="true" Text="For Sale" GroupName="radio" runat="server" ></asp:RadioButton>

                   <asp:RadioButton ID="rbtnfr" Text="For Rent" GroupName="radio" runat="server" ></asp:RadioButton>
                   <span style="font-size: x-small; font-family: Arial; ">       
                   <span style="text-decoration: underline">Select Atleast One Option</span></span><br />
                  <%-- <asp:Label ID="lblerror" ForeColor="Red" runat="server" Text=""></asp:Label>--%>

                   </td>
               </tr>
               <tr>
                   <td style="width: 125px">
                       <span style="font-size: small; font-family: Arial">Keyword :
                   </td>
                   <td style="width: 416px">
                       <asp:TextBox  ID="txtkeyword" runat="server" Width="167px"></asp:TextBox>
                   </td>
               </tr>
               <tr>
                   <td style="width: 125px">
                       <span style="font-size: small; font-family: Arial">Property Type :
                   </span>
                   <span style="color: #FF0000">*</span></td>
                   <td style="width: 416px">
                       <asp:DropDownList ID="ddlpropertytype" runat="server" CssClass="validate[required] radio"
                       Width="169px">
                       <asp:ListItem Value="">--Select--</asp:ListItem>
                       <asp:ListItem Value="Commercial">Commercial</asp:ListItem>
                       <asp:ListItem Value="Residential">Residential</asp:ListItem>
                       <asp:ListItem Value="Plot">Plot</asp:ListItem>
                       <asp:ListItem Value="Bunglow">Bunglow</asp:ListItem>
                       <asp:ListItem Value="Villa">Villa</asp:ListItem>
                   </asp:DropDownList>
                   </td>
               </tr>
               <tr>
                   <td style="width: 125px">
                       <span style="font-size: small; font-family: Arial">City :
                   </span>
                   <span style="color: #FF0000">*</span></td>
                   <td style="width: 416px"><asp:DropDownList ID="ddlcity" runat="server" Width="169px" CssClass="validate[required] radio">
                           <asp:ListItem Value="">--Select--</asp:ListItem>

                       </asp:DropDownList>
                   </td>
               </tr>
               <tr>
                   <td style="width: 125px">
                       <span style="font-size: small; font-family: Arial">Locality :</span>
                   <span style="color: #FF0000">*</span></td>
                   <td style="width: 416px">
                       <asp:DropDownList ID="ddllocality" runat="server" Width="169px" CssClass="validate[required] radio">
                       <asp:ListItem Value="">--Select--</asp:ListItem>

                       </asp:DropDownList>
                   </td>
               </tr>
               <tr>
                   <td style="width: 125px">
                       <span style="font-size: small; font-family: Arial">Price :
                   </span>
                   <span style="color: #FF0000">*</span></td>
                   <td style="width: 416px">
                       <asp:DropDownList ID="ddlprice" runat="server"
                           CssClass="validate[required] radio" Height="20px" Width="169px">
                       <asp:ListItem Value="">--Select--</asp:ListItem>
                       <asp:ListItem Value="1">5 to  10 Thousand</asp:ListItem>
                       <asp:ListItem Value="2">10 to 25 Thousand</asp:ListItem>
                       <asp:ListItem Value="3">25 to 50 Thousand</asp:ListItem>
                       <asp:ListItem Value="4">50 to 75 Thousand</asp:ListItem>
                       <asp:ListItem Value="5">75 to 85 Thousand</asp:ListItem>
                       <asp:ListItem Value="6">85 to 100 Thousand</asp:ListItem>
                       <asp:ListItem Value="7">1 to 10 Lakhs</asp:ListItem>
                       <asp:ListItem Value="8">10 to 25 Lakhs</asp:ListItem>
                       <asp:ListItem Value="9">25 to 35 Lakhs</asp:ListItem>
                       <asp:ListItem Value="10">35 to 45 Lakhs</asp:ListItem>
                       <asp:ListItem Value="11">45 to 55 Lakhs</asp:ListItem>
                       <asp:ListItem Value="12">55 to 65 Lakhs</asp:ListItem>
                       <asp:ListItem Value="13">65 to 75 lakhs</asp:ListItem>
                       <asp:ListItem Value="14">75 to 85 Lakhs</asp:ListItem>
                       <asp:ListItem Value="15">85 to 100 Lakhs</asp:ListItem>
                        <asp:ListItem Value="15">1 to 1.5 Crores</asp:ListItem>
                         <asp:ListItem Value="15">1.5  to 2 Crores</asp:ListItem>
                          <asp:ListItem Value="15">2 to 2.5 Crores</asp:ListItem>
                         <asp:ListItem Value="15">2.5  to 3 Crores</asp:ListItem>
                          <asp:ListItem Value="15">3 to 5 Crores</asp:ListItem>
                         <asp:ListItem Value="15">5  to 10 Crores</asp:ListItem>
                          <asp:ListItem Value="15">1o to 15 Crores</asp:ListItem>
                         <asp:ListItem Value="15">15  to 25 Crores</asp:ListItem>
                          <asp:ListItem Value="15">25 to 35 Crores</asp:ListItem>
                         <asp:ListItem Value="15">35  to 45 Crores</asp:ListItem>
                          <asp:ListItem Value="15">45 to 55 Crores</asp:ListItem>
                         <asp:ListItem Value="15">55  to 65 Crores</asp:ListItem>
                          <asp:ListItem Value="15">65 to 75 Crores</asp:ListItem>
                         <asp:ListItem Value="15">75  to 85 Crores</asp:ListItem>
                         <asp:ListItem Value="15">85  to 100 Crores</asp:ListItem>

                   </asp:DropDownList>


                   </td>
               </tr>
               <tr>
                   <td style="width: 125px">
                       <span style="font-size: small; font-family: Arial">Bedroom :</td>
                   <td style="width: 416px">
                       <asp:DropDownList ID="ddlbedrooms" runat="server"
                       Width="169px">
                       <asp:ListItem Value="">--Select--</asp:ListItem>
                       <asp:ListItem Value="1">0</asp:ListItem>
                       <asp:ListItem Value="2">1</asp:ListItem>
                       <asp:ListItem Value="3">2</asp:ListItem>
                       <asp:ListItem Value="4">3</asp:ListItem>
                       <asp:ListItem Value="5">4</asp:ListItem>
                       <asp:ListItem Value="6">5</asp:ListItem>
                       <asp:ListItem Value="7">6</asp:ListItem>
                       <asp:ListItem Value="8">7</asp:ListItem>
                       <asp:ListItem Value="9">8</asp:ListItem>
                       <asp:ListItem Value="10">9</asp:ListItem>
                       <asp:ListItem Value="11">10</asp:ListItem>


                   </asp:DropDownList>
                   </td>
               </tr>
               <tr>
                   <td style="width: 125px">
                       <span style="font-size: small; font-family: Arial">Built Up Area :</span>
                   <span style="color: #FF0000">*</span></td>
                   <td style="width: 416px" height="34px">
                       <asp:TextBox ID="txtminarea" runat="server" Height="18px" Width="53px" CssClass="validate[required,custom[number]]"></asp:TextBox>
                        
                       <asp:TextBox ID="txtmaxarea" runat="server" Height="18px" Width="52px" CssClass="validate[required,custom[number]]"></asp:TextBox>
                         
                       <asp:DropDownList ID="ddlarea" runat="server" CssClass="validate[required] radio">
                       <asp:ListItem Value="">--Select--</asp:ListItem>
                       <asp:ListItem Value="fe">sqft</asp:ListItem>
                       <asp:ListItem Value="me">sqm</asp:ListItem>
                       <asp:ListItem Value="ya">sqyds</asp:ListItem>

                       </asp:DropDownList>
                   </td>
               </tr>
               <tr>
                   <td style="width: 125px">
                        
                   </td>
                   <td style="width: 416px">
                       <asp:Button class="btn" ID="btnSubmit" runat="server" Text="Search" Width="75px"
                           onclick="btnSubmit_Click" />
                    <asp:Button class="btn" ID="btnreset" runat="server" Text="Reset"
                           UseSubmitBehavior="false" Width="75px" onclick="btnreset_Click"/>
                   </td>
               </tr>
           </table>
       </div>

推荐答案

以DEBUG模式运行解决方案,在SqlCommand处放置一个断点,并检查查询的外观.
复制strQ变量的值,然后在SQL Management Studio或Visual Studio中执行,然后查看错误的位置.
我们几乎不可能调试您的SQL查询.从最初的外观来看,您正在使用的Between子句中似乎有错误.
Between子句期望值1和值2,在查询中传递"75至85万"之间类似的内容.
Run the solution in DEBUG mode, put a break point at SqlCommand and check how the query looks like.
Copy the value of strQ variable, and execute in SQL management studio or in Visual Studio and see where the error is.
It is next to impossible for us to debug your SQL query. From the initial looks for me it looks like there is an error in the Between clause that you are using.
Between clause expects Value1 AND Value2, where as your query is passing something similar between ''75 to 85 lakhs''.


这篇关于从前端搜索数据库或多个条件...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆