473,396 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Add 'OR' with AddWhere?

12
Hi all, I wanted to make a search function where you can type a word in one field, now I use this:
Expand|Select|Wrap|Line Numbers
  1. query.AddWhere(CalendarItem.Columns.Description, Comparison.Like, "%" + SearchTextBox.Text + "%");
  2. query.AddWhere(CalendarItem.Columns.Location, Comparison.Like, "%" + SearchTextBox.Text + "%");
  3.  
But then the word has to be in Description AND in Location, but I was wondering, can I make it that the word can be in Description, Or in location, something like the following, but this isn't working!!!!!!

Expand|Select|Wrap|Line Numbers
  1. query.AddWhere(CalendarItem.Columns.Description, Comparison.Like, "%" + SearchTextBox.Text + "%" OR CalendarItem.Columns.Location, Comparison.Like, "%" + SearchTextBox.Text + "%");

->Is it also possible to sort this query on for instance 'Date'? (column in database)
I really have no idea how to do this..


Can somebody help me? thank you!
Sep 17 '07 #1
12 3731
BD5
12
Anybody please? :)

///
Sep 18 '07 #2
Plater
7,872 Expert 4TB
I could not find anything on the AddWhere() function not the Comparison.Like in msdn.

Perhaps it would be more helpful if you explained what object-types you were using, since you never said.

Also, is this for a web-application or a windows application? it can make a big difference sometimes.
Sep 18 '07 #3
BD5
12
I could not find anything on the AddWhere() function not the Comparison.Like in msdn.

Perhaps it would be more helpful if you explained what object-types you were using, since you never said.

Also, is this for a web-application or a windows application? it can make a big difference sometimes.
Hi, thanks for your reply!

It is for a web application. About the object types, I am not sure what you mean (I am kind of a newb to ASP, but I am trying :)). If you mean string etc, well Description is of the type ntext, and the other colums the search should be going through are colums, all nvarchar(255) types..

I hope this is what you meant with object type?
Sep 18 '07 #4
Plater
7,872 Expert 4TB
What is "query" it's not a string or an int, it's some kind of object. Knowing that would be most helpful.
Sep 19 '07 #5
BD5
12
Hi,

I hope you mean this :):

Expand|Select|Wrap|Line Numbers
  1. protected void SearchButton_Click(object sender, EventArgs e)
  2.     {
  3. Query query = CalendarItem.CreateQuery();
  4.  
  5. query.AddWhere(CalendarItem.Columns.Description, Comparison.Like, "%" + SearchTextBox.Text + "%");
  6. query.AddWhere(CalendarItem.Columns.IsPublished, true);
  7.  
  8. LoadAndBindQuery(query);
  9.  
  10.     }
  11.  
Sep 19 '07 #6
Plater
7,872 Expert 4TB
Yes, I do not have this "Query" object nor can I find in on msdn.
Maybe someone who has used it before can help, because I can't find any info about it.
Sep 19 '07 #7
BD5
12
I found this about it:

http://www.codeproject.com/cs/databa...eryBuilder.asp


If you look at complex queries, they use this:

Expand|Select|Wrap|Line Numbers
  1. query.AddWhere("CustomerID", Comparison.Equals, 
  2.                                    "VINET", 1);
  3. query.AddWhere("OrderDate", Comparison.LessThan, 
  4.                      new DateTime(2005,1,1), 1);
  5.  
  6. // Add first 'Or...' column to level 2
  7. query.AddWhere("CustomerID", Comparison.Equals, "TOMSP", 2);
  8. query.AddWhere("OrderDate", Comparison.LessThan, 
  9.                     new DateTime(2004,6,30), 2);
  10.  

You can see the numbers, I suppose they are different 'layers' in Or statements? I tried to do it this way, adding ,1 and ,2 in my query.Addwhere , but that doesn't work with me..
Sep 19 '07 #8
Plater
7,872 Expert 4TB
I always build my queries by hand with a string, the "old school" way.

I cannot find anything in MSDN about "SelectQueryBuilder" either.

Are you using some 3rd party software?
Sep 19 '07 #9
BD5
12
Subsonic..

If you mean that...
Sep 19 '07 #10
Plater
7,872 Expert 4TB
It sounds like you would be better off directing your questions to "subsonic" then if they're some thirdparty plugin software.
Subsonic..

If you mean that...
Sep 19 '07 #11
BD5
12
Yeah, but I didn't find a subcategory in this forum..

maybe someone else knows how to deal with this?
Sep 19 '07 #12
Plater
7,872 Expert 4TB
There's not a subcatagory because it's a 3rd party software.
I ment you should go talk with the people who made the software.
Sep 20 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Andrea A | last post by:
Hi, i'm developing a website that will have an huge amount of visitors a day --> it will be a contest with 100.000$ of prize. I'm concerning about using a template class (and which one do you...
12
by: Phil Powell | last post by:
The customer made a wild request: they want on their admin panel a textarea that will display an existing resume. This textarea, however, must have a dynamic width, one that "fills the screen...
6
by: juglesh | last post by:
hi, I'm just getting started here in php, but i've been able to get some basic variable stuff working, so I'm just looking for advice on the basic set up of some thumbnail->picture pages. the...
8
by: DJ Craig | last post by:
I use a web hosting service that gives me FTP access to my directory on a Linux server. I use Mac OS X. I write my code in Dreamweaver MX which gives me color-coding, but I get really tired of...
4
by: Chris | last post by:
Having a little trouble returning the result I'm looking for in a query and thought I'd ask a question here. I have an input screen with a pull down menu to capture vacation activity within a...
3
by: Jim J | last post by:
I have been trying to find some kind of authentication method or script (PHP/perl/javascript or other) to achieve the following, with no luck. Say there are 100 files at a site. A person can...
21
by: Gavin | last post by:
Hi, I'm a newbie to programming of any kind. I have posted this to other groups in a hope to get a response from anyone. Can any one tell me how to make my VB program read the Bios serial number...
7
by: Dan. | last post by:
hi, i'm sorry to bother you; but i was wondering what the function of the OR operator was in terms of numbers: num0 = num1 or num2 i wrote me a little thing to try and see the effects and if...
2
by: Hmmm... | last post by:
Is there a way to control which controls appear to be "on top". For example a MaskEdBox shows up "on top" of a ComboBox when the 2 controls overlap, but a MaskedBox shows up "underneath" a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.