DataSource Controls :: Sql Query Syntax For Advanced Search With Dropdownlists
Feb 16, 2010
I want to be able to make a query from three dropdownlists but not all three have to be selected to create results. This is what I have so far :
sub getdata (src as object, e as eventargs)
dim strsql as string
dim myconnection as oledbconnection
dim mycommand as oledbcommand
myconnection = new oledbconnection(ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_csrdb"))
strsql ="SELECT tbl_case.Case_id, tbl_case.Title, tbl_case.Description, Tbl_Country.Country_Name, tbl_principle.Principle_Name," _
& "tbl_keyword.Keyword FROM tbl_keyword INNER JOIN ((tbl_principle INNER JOIN (Tbl_Country INNER JOIN tbl_case ON Tbl_Country.Country_Id
tbl_case.country) ON tbl_principle.Principle_ID = tbl_case.Principle) INNER JOIN tbl_Usedkeywords ON tbl_case.Case_id
= tbl_Usedkeywords.case) ON tbl_keyword.Keyword_id = tbl_Usedkeywords.keyword " _
& "WHERE "
if DLPrinciple.selectedindex=0 then
strsql = strsql & "((tbl_principle.Principle_Name) like '%')"
else
if DLCountry.Selectedindex=0 then
strsql = strsql & "((tbl_country.country_Name) like '%')"
else
if DLKeyword.selectedindex=0 then
strsql = strsql & "((tbl_keyword.Keyword) like '%')"
else
strsql = strsql & "((tbl_principle.principle_Name) = '" & session("infoprinciple") & "')" + "((tbl_country.country_Name) = '" & session("infoland") & "')" + "((tbl_keyword.keyword) = '" & session("infokeyword") & "')"
end if
end if
end if
This is working perfectly with only one dropdownlist but I can not figure out how to make it work with several.
View 14 Replies
Similar Messages:
Jan 25, 2010
I have a query which is returning records like below which returns a list of tasks with a corresponding task type. there is a task table (wh_task) and a task type table (wh_task_type). What i want to achieve is a count of all the tickets per ticket type. So at the end of the query i will have a total for Administration / Maintenance tasks (1) and a total for Routine Maintenance Tasks (3). ** and all the other types *
There are many different types of task type so I dont want to have to hard code it. Can count all the occurencies of the different ticket types.
Task Name
Task Type
Date Completed
SBS Server C drive running out of space
Administration / Maintenance
16/07/2007 16:03:34
Patching Server(s).
Routine Maintenance
08/01/2009 06:51:56
Patching Server(s).
Routine Maintenance
11/02/2009 10:06:06
Patching Server(s).
Routine Maintenance
04/05/2009 06:53:24
I can also get wh_task_type_id.
Here is my SQL:
[Code]....
View 8 Replies
Mar 29, 2010
I am tring to build a page with advanced search options. Here is my code am I on the right path. What I wnat this to do is if you put something in any one of the textboxes it will filter by that column.
<%@ Page language="C#" masterpagefile="MainContent.master" title="Electrical Storage" EnableEventValidation="false" %>
<asp:Content id="Content1" runat="server" contentplaceholderid="Content">
<div id="Rightside">
<h2>Search Electrical Storage
</h2>
<li><a href="EStorageResultsAll.aspx">View All Files</a></li>
<li>Specify Projects to View</li>
<form>
<table style="width: 500px">
<tr><td></td>
<td>Company ID</td>
<td><asp:TextBox runat="server" id="CoID" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>Project Class</td>
<td><asp:TextBox runat="server" id="ProjClass" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>Project</td>
<td><asp:TextBox runat="server" id="Proj" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>File Name</td>
<td><asp:TextBox runat="server" id="FileName" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>File Number</td>
<td><asp:TextBox runat="server" id="FileNumber" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>File Additional Info</td>
<td><asp:TextBox runat="server" id="FileAdd" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>Box Number</td>
<td><asp:TextBox runat="server" id="BoxNumber" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td><asp:Button runat="server" Text="Search" id="Button1"></asp:Button></td>
<td></td>
</tr>
</table>
<hr />
<asp:GridView id="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" DataSourceID="AccessDataSource1" ForeColor="Black" Width="820px" AllowSorting="True">
<RowStyle BackColor="White" />
<Columns>
<asp:boundfield DataField="CoID" HeaderText="Co ID" SortExpression="CoID">
</asp:boundfield>
<asp:boundfield DataField="ProjClass" HeaderText="Project Class" SortExpression="ProjClass">
</asp:boundfield>
<asp:boundfield DataField="Project" HeaderText="Project" SortExpression="Project">
</asp:boundfield>
<asp:boundfield DataField="FileName" HeaderText="File Name" SortExpression="FileName">
</asp:boundfield>
<asp:boundfield DataField="FileAddInfo" HeaderText="File Add Info" SortExpression="FileAddInfo">
</asp:boundfield>
<asp:boundfield DataField="FileNumber" HeaderText="File Number" SortExpression="FileNumber">
</asp:boundfield>
<asp:boundfield DataField="BoxNumber" HeaderText="Box Number" SortExpression="BoxNumber">
</asp:boundfield>
<asp:boundfield DataField="Location" HeaderText="Location" SortExpression="Location">
</asp:boundfield>
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000066" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="\Elec1DATABASEStorageElectricalFilesBook.mdb" SelectCommand="SELECT [CoID], [ProjClass], [Project], [FileName], [FileAddInfo],
[FileNumber], [BoxNumber], [Location] FROM [FilesWithLocation] WHERE (([CoID] LIKE '%' + ? + '%') OR ([ProjClass] LIKE '%' + ? + '%') OR ([Project] LIKE '%' + ? + '%') OR ([FileName] LIKE '%' + ? + '%') OR ([FileAddInfo] LIKE '%' + ? + '%') OR ([FileNumber]
LIKE '%' + ? + '%') OR ([BoxNumber] LIKE '%' + ? + '%'))">
<SelectParameters>
<asp:controlparameter ControlID="CoID" Name="CoID" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="ProjClass" Name="ProjClass" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="Proj" Name="Project" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="FileName" Name="FileName" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="FileAdd" Name="FileAddInfo" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="FileNumber" Name="FileNumber" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="BoxNumber" Name="BoxNumber" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
</form>
</div>
</asp:Content>
<asp:Content id="Content2" runat="server" contentplaceholderid="head">
<style type="text/css">
</style>
</asp:Content>
View 2 Replies
May 3, 2010
I have this SqlDataSource:
[Code]....But when I click Button Update this error occurred:
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.
View 5 Replies
May 27, 2010
I'm looking for something similar to EasyQuery. Some sort of control that lets the user or the admin to select some tables, then some columns for the tables and the conditions, so he can do the query without entering the mysql sentence, only selecting the tables and the rows...
View 1 Replies
Nov 21, 2010
I am wondering if there are any good articles you could point me to that would present the implementation details or options for delivering advanced search capabilities. Like what we see at [url] and similar Web sites offering vast numbers of products to be searched. The search process for these starts with a simple "Search" text box - usually with auto-suggest. Then the user can drill down and narrow the search by [for example] price, manufacture, size, capacity, and other relevant attributes of the product being searched.
When I navigate such sites and search for products, drilling down into the various categories, it's easy to think that there is some complex engine behind the scenes that generates dynamic SQL to satisfy the various and potentially extensive criterion required to satisfy the search requests.
Or could it be simpler than that? In any case, I understand this question may not have a specific answer; so I'm hoping for some article or reference implementation I could study. Short of that, if any of you have implemented advanced search of a product catalog (presumably searching products stored in a reasonably normalized database; through 3NF or so); any critical implementation considerations would be appreciated. I'm particularly interested in the meta data that may have to be present in the underlying data set in order to satisfy some of the search requests.
View 2 Replies
Feb 28, 2010
I'm developing an ASP.NET application which has allows users to search for other users based on their name. This search is done using Linq to SQL. At the moment, I've only got 10 or so users in my database, so I can't really test the efficiency of my search query. I'm new to testing and such, but what is the best way to simulate 100/1000/10000 users on a query? Is there a tool (preferably free) that would allow me to perform tests to see how quickly the database can be searched if it had x number of users?
View 1 Replies
Jun 1, 2010
I've been reading up on SQL Injection and want to go back and implement some measures to prevent these kinds of potential attacks.For example, on our company intranet, we have an address book feature and a search function so the user is able to look a company or a person up from the database/The user will enter their query into a TextBox control and click the Submit button, calling the following function:addybookDS1.SelectCommand = "SELECT * FROM [addressbook] WHERE COMPANY LIKE '%" + search1 + "%' OR CONTACT LIKE '%" + search1 + "%' OR LASTNAME LIKE '%" + search1 + "%' OR EMAIL LIKE '%" + search1 + "%'"search1 is the TextBox controlI had previously implemented this measure:search1 = Replace(search1, "'", "''")But I want to know if there is more I can do here and how I can go about doing it.
View 16 Replies
Aug 14, 2010
I'm working on a asp.net forms web application where I've got advanced search form with grid listing results below. Grid is sortable and pageable. Grid is listing products.
I've got two requirements :
1) make the url remember the advanced search form state so search results page can be bookmarked etc.
2) on the product details page there is a back button that should take the user to the advanced search page with the same settings in the form and same grid state.
I have implemented a workaround to above two problems but I don't think my solution is very clean and I'd like to hear better ideas. My workaround is as follows :
1) I iterate through form fields and I put values into the querystring after the hash. So when the page is loaded it gets the values from url if available.
2) when user clicks a link to product details page from the grid I use javascript to create a cookie with url to advanced search page so when rendering the product details page I know the url for the back button.
View 1 Replies
Jul 6, 2010
hope you guys are doing well! I have a question and no answer yet how to do it. Right now i can have 1 dropdownlist and when i press on my search button its show the result of the query the user ask
but how to do it with two seperates dropdownlist ? isnt it with inner join ? also if the value is null what to do ?
here is my sample little code for a sample search
[Code]....
View 1 Replies
Aug 8, 2010
I'm having problem in inserting text from a textbox in which user write or copy some text which may contain special characters ( " , . ) etc. If there is any special character it get conflict with CommandText Syntax and generates error in inserting. I want to insert all these characters. How could i do it?
Code:
[code]....
View 1 Replies
Apr 29, 2010
I am using this code to find titles depending on user criteria:
[Code]....
The search is non-english charachters, and it has some problems. when you looks for "Marker" and in database you have this title: "Markers" it won't find it..... This search just not good enough and I am looking to replace it urgently....
View 6 Replies
Jan 29, 2010
I am trying to create strogly typed datasets for my project. When I right click on the xsd file that I need to generate a strongly typed dataset for I can't find the 'Advanced' properties as described in the below article (almost half way down)[URL]As I do not see the Advanced properties option I can't find the 'Custom Tool' property/option to set its value to 'MSDatasetGenerator'. Do I have to install some kind of patch on my VS 2005?
View 5 Replies
Jan 27, 2010
I want a word search i doing the search like this , but it is giving character wherever there is in the string,if i give two character like ok it is searching for a full string where ever Ok is there select * from table1 where textfield like '%word%' this query would match word but also wordabc how can i make it aware of delimitions
View 3 Replies
Mar 29, 2010
I am using SQL Server 2008 and Full Text search.
Its working fine for PDF / doc files but not working for .JPG files.
Basically i have some document scanned and stored it in varbinnary datatype in DB.
I am able to search for .doc /.xml /.pdf files .. but not able to search .jpg.
also i am not getting ".jgp" extension in result of following query
SELECT document_type, version, manufacturer
FROM sys.fulltext_document_types order by document_type
View 1 Replies
Jul 16, 2010
I'm attempting to hook up multiple DropDownLists to a single SQLDataSource, but I want the SQLDataSource to return different rows depending on which DropDownList it is populating.
Say I have a table full of names (we'll call it TABLE_NAMES):
[code]....
....and I have two dropdown lists, one with a list of person names and one with a list of dog names.
Is there a way to link up each of these dropdown lists to a single SQLDataSource and use the SelectParameter to differentiate between which records I want returned for each dropdown list?
To make matters worse, these dropdown lists will appear within a GridView control....so there will be multiple instances of each dropdown list depending on how many rows there are in the GridView.
View 1 Replies
Feb 13, 2010
How i can make the normal search string to sql server full text search parse, because when we are user enyer search text "how to run windows schedule in C#", in database we have article to to this, but data not returning and sometime is say error in key word and etc.
View 1 Replies
Jan 18, 2010
now have tried to locate and find anything about how to make a
TEXTBOX and A Button "Search"
Problem is that I have made this "bellow" and when I then enter a "value" into texbox2 and hit enter on the button it wont show me the "emnenummer" that I have requested.
im not even sure this is the correct way to do a "search"
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><asp:Button ID="Button1"
runat="server" Text="Button" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"[code]....
View 3 Replies
Mar 29, 2011
Dim connStr As String = " Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=W:PatioOrderApp_DataPatio.mdb"
Dim con As New OleDb.OleDbConnection(connStr)
Dim instr As String = " INSERT INTO tOrders([first_name],[last_name],[order],[comment]) Valuse(?,?,?,?)"
If IsValid Then
Using con
Using cmd As New OleDb.OleDbCommand(instr, con)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("first_name", DBNull.Value)
cmd.Parameters.AddWithValue("last_name", DBNull.Value)
cmd.Parameters.AddWithValue("order", DBNull.Value)
cmd.Parameters.AddWithValue("comment", menuDrinks.SelectedItem.ToString)
con.Open()
cmd.ExecuteNonQuery()
End Using
End Using
con.Close()
End If
View 1 Replies
Aug 22, 2010
1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like
SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.
Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).
2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query
(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).
If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.
View 11 Replies
Jan 15, 2010
[code]...
This query works perfectly on the query analyser.
But when configuring the Table adapter ,I try executing the query and i get 0 rows affected.
What could I be getting wrong in this case.
NB:Existing GalleryID has been supplied.
View 1 Replies
May 17, 2010
By right clicking on my database i created a query in server explorer. But where are this query stored can't find them back. I should aspect that their is a folder query's like there is a folder tables but this isn't the case.
View 10 Replies
Jan 30, 2011
i have the following code:
[Code]....
3 nested dropdownlists SELECTing from DB. So i select the brand, then i select the model and then i select the product and click on SEARCH button.
But when i select thebrand, and then the model, and if i want to change the brand, it does not reset the second and third dropdownlists.
View 3 Replies
Jan 3, 2011
I have this Insert statement working fine: [Code]....
It inserts a new record into a single table. The PK is a field named QID.what the equivalent Update code would be? I'm not sure of the syntax for the Update values (old and new) and Where clause.I'm assuming something beginning with: existingQ.Update
View 2 Replies
Jan 9, 2010
here is my update query syntax.my problem is.if i update only logo1 and logo3 with null logo2 and img null then my query should be update the other record.just dont update null value record but other should be update.but below my query can not update any record.
UPDATE tbitem set itemname= @itemname,note=@note,
price=@price,qty=@qty,logo1=@logo1,
logo2=@logo2,logo3=@logo3,img=@img
where id =@id
and @logo1 is
null and @logo2
is null
and @logo3
is null
and @img is
null
View 1 Replies