![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
18 Year Old Programmer
Join Date: Jan 2008
Posts: 26
Rep Power: 0
![]() |
Preforming a binary(SQL) search on a datagrid.
Hey, all. I have another problem that we're running into with our project.
We use data grids to handle the viewing of the main tables in our program, those tables being Employees, Invoices(Masters + Items), and Purchase Orders(Masters + items), and we're setting up a search function for them. We have one working. The only problem is that it's a serial search, running through the whole data grid to find what it's looking for. That's fine for small tables, but in a search like that, it becomes impractical when there are thousands of records like there would potentially be in an A/P system. There would be tremendous system slowdown, and I'm sure I'm not the only one who sees it as bad practice. So, I'm wanting to preform a binary search, and I talked it over with my teacher. He said that I need to find a way to move the record pointer in the data grid without refreshing the data in the data grid, as the only thing I can think that's close to a binary search is preforming select queries based on the search parameters and eliminating all irrelevant data. I don't know if that's called anything different, but it's really the only way I know, and my teacher shot that down. I guess what I'm asking is, is there any way to change the record pointer location of a data grid based on a SQL Select query, or is there a special SQL function for binary searches? Any help is much appreciated. Thanks. =]
__________________
Tier 2 Hardware Technician Net Effects, LLC Brunswick, Ohio |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,791
Rep Power: 5
![]() |
Re: Preforming a binary(SQL) search on a datagrid.
Will the parameter that's being searched for either be an exact match or not?
If it is a 'match or no match' situation, can you not perform a MySQL SELECT statement that searches for that particular row? Then retrieve the row number of that record. Using the row number you can do whatever you need to your data grid, since the row number should correspond to the same row in your graphical interface's table. I'm assuming your data is being represented in the same order and size as your MySQL table. Or am I missing something? |
|
|
|
|
|
#3 |
|
18 Year Old Programmer
Join Date: Jan 2008
Posts: 26
Rep Power: 0
![]() |
Re: Preforming a binary(SQL) search on a datagrid.
It's going to be a dynamic search, in that it will change the results every time the key is pressed. The where clause is going to be a "LIKE", and not an "=" if that's what you mean.
I'm thinking of doing a Select statement, having that return a row, and then using that row to change the bindingcontext.location property of the form. I just don't know what I would reference to do that. I don't think I'd use the PK of the returned row to find it and then change the location... That seems extremely round-about. But is that how it would be done? Also, if it helps any, we're using MSSQL.
__________________
Tier 2 Hardware Technician Net Effects, LLC Brunswick, Ohio |
|
|
|
|
|
#4 | ||
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,791
Rep Power: 5
![]() |
Re: Preforming a binary(SQL) search on a datagrid.
Quote:
Quote:
So after you've done that, you then know the row number that matches the search query. Just reference that row number in the grid data and change its appearance. You can figure out how to do this by looking at the documentation for the GUI control you're using. This object will have methods that you can call, one of which should be able to modify the apperance of row #X. These methods will be listed along with their usage in their respective documentation. |
||
|
|
|
|
|
#5 |
|
18 Year Old Programmer
Join Date: Jan 2008
Posts: 26
Rep Power: 0
![]() |
Re: Preforming a binary(SQL) search on a datagrid.
I think we may have just found it.
When you assign a datasource to a data grid in .Net, it uses something called BindingContext to handle all interfacing with that datasource. So, after speaking with a co-developer who is also on the project, and looking more in depth at how the search function works, we found that we could bind the Search textbox to the same Datasource as the data grid. By doing this, every time something is changed in the text box, it will change the location of the record pointer in the datasource, and the data grid will act accordingly to that change. We are testing it now. If it works, I will paste the code for anyone who has a similar problem, complete with documentation.
__________________
Tier 2 Hardware Technician Net Effects, LLC Brunswick, Ohio |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to save all search engine results urls in a text file | abojan | ASP | 0 | Dec 27th, 2006 8:33 AM |
| Exporting a Datagrid to Excel problem | Mortavitch | Visual Basic .NET | 0 | Jul 14th, 2006 9:34 PM |
| Backup Search | grimpirate | C | 3 | Jul 3rd, 2006 7:49 PM |
| How can I disable particular rows in a datagrid? | HappyTomato | C# | 2 | Aug 25th, 2005 3:48 PM |
| An alternative to 'Windows Search'... | SaturN | Coder's Corner Lounge | 9 | Jul 24th, 2005 2:30 PM |