Click here to Skip to main content
15,868,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
at the moment the database im working with i cannot change the names, so im stuck with names that will not work very well in the WHERE statements and i belive i cannot use alias in WHERE statements either.

(see attached for screen shot of current form)http://s18.postimage.org/7s4it1srd/form_screenshot_with_code_behind.png[^]

my goal is:-
a user can input two sizes on the top left hand side of my form,

Across =90
Around =50

these two sizes will then have a range to them i.e. more or less than 5 (next two boxes below them called range)

once i click the search button the 4 boxes on the right will be populated with the upper and lower limits for each size dependent on the range
90 - 5 = 85 (check1.text)
90+ 5 = 95(check2.text)
50 - 5 = 45(check3.text)
50 +5 = 55 (check4.text)

This is so far where i have got to & all is working good.

what i want to do with these 4 numbers is filter my datagridview at the bottom to reflect the users inputs.

what i would like to see happen when i click the search button is
(very bad non coding here - but i want is to filter my datagridview result via a range against Across & Round)
Add to the search button coding maybe,

datagridview1 update( [MM-Across].value is > check1.text but < check2.text AND ALSO [MM-Round].value is > Check3.text but <check4.text),>

im a complete novice to VB & SQL i must admit but im trying to self learn, but im really stuck on this section.


Thank you in advance for any support or help you could offer me,a few projects on here was the closest i can find on the net to what i want to roughly do after 5 hours of looking today)

NaZReD

UK
Posted
Updated 24-Nov-12 6:21am
v2
Comments
NaZReD 24-Nov-12 12:01pm    
i need to upload pic so you can see screenshot, didnt notice there isnt an option on here for that after i posted
Nelek 24-Nov-12 12:05pm    
You can upload it to an internet site and add the link to your question.
To add information / edit content you can use the "improve question" widget.
NaZReD 24-Nov-12 12:23pm    
done thank you, check if link works for you please x
Nelek 24-Nov-12 13:50pm    
You are welcome. And Yes, it is working

1 solution

Have a look at the Bindingsource Filter property, this will filter the current dataset within the bound DGV without a call back to the database, so you could select an initial bunch of records based on an outerboundary and then filter locally within a criteria.

The Filter property effectively adds an SQL WHERE clause locally.

The next thing to consider is the SQL BETWEEN statement. Rather than having an pair of outer checks, you can use a single BETWEEN.

So, you could have something like; Select * where something BETWEEN 5 AND 10.


I used this approach when working with a bunch of event/alarm records. I initially called and populated the view with a outer range based on records between 2 dates and pulled these back to the client. The user then filter based on other criteria, e.g. tag names, alarm groups using the FILTER property.

Also, if you are working with a large dataset, make sure you pull back the data asynchronously, so the UI doesn't stall while data is being searched for in the database.

Hope these are a few things to help your research a bit more :)
 
Share this answer
 
v2
Comments
NaZReD 24-Nov-12 12:07pm    
that database that i am using has heading like MM-Across... so i cant use this header in a SQL WHERE i think.

if i can filter locally using this Datagridview filter property this would be awesome!, im unsure how i go about using the property, i will search the net a bit, unless you can help with a few example lines of code explaining how to use it
Thank you for quick response!
NaZReD 24-Nov-12 12:18pm    
is this a something like
datagridview. *filter* .. or do i need to connect to the table adapter ?
DaveAuld 24-Nov-12 12:24pm    
Sorry, I made a slight mistake, you use a bindsource to link the DGV to the db, then you update the filter property of the bindingsource. Go to the MSDN site and search for "Forms over Data", there is an excellent video that shows how all the databinding hangs together.
NaZReD 24-Nov-12 13:07pm    
http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.filter.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

i found the above but, it talking about a newdata or type the dataout in the code, can i link this with a MS database connection?!
NaZReD 24-Nov-12 14:09pm    
nope im lost. i already have a dataconection that is displaying in a DGV, all i want to do is refine / filter this data using a text box

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900