Click here to Skip to main content
15,741,692 members
Please Sign up or sign in to vote.
4.97/5 (31 votes)
See more:
Hi guys,

I'm working on a simple programming to read/write to database(using MS Access).

MY DB:

ID_ ADDRESS_ CONTACT_NO_
(3 columns)

Now in Windows Form, if searched for an address, I want all the the address (which is in Db) if matched with the searched text, to be listed in a listbox(optional, or something else).
Then I will choose from the list a particular address(by double-click) to show the other information of it in textboxes.

Now I'm working it, able to read the data from DB and put it the data in DataTable.
I use Regex to find the matched searched item and what I need to do next?

I'm out of ideas.

Maybe I can put all the matched item to a listbox.
But after I double-click a item from listbox I need to call again the DataTable to get back the other information for that particular address.
I guess this is not good.

Can you guys suggest me away to do this?

Please dont suggest me with source codes, I just need your ideas. The source codes, I will try to work on myself.

Thanks,
Skunkhead :)
Posted
Updated 31-Jan-11 21:12pm
v3
Comments
Amit Kumar Tiwari 1-Feb-11 1:59am    
|Please dont suggest me with source codes, I just need your ideas|

Brave fellow. Real developer :) Appreciated.
OriginalGriff 1-Feb-11 2:02am    
"Please dont suggest me with source codes, I just need your ideas. The source codes, i will try to work on myself."

Well done: gets my 5!
JF2015 1-Feb-11 2:44am    
Awesome - It's a very rare occassion, that someone here tries to find the correct source code on their own. 5+
Dalek Dave 1-Feb-11 3:13am    
Edited for Grammar and Readability, but a great question.
Sandeep Mewara 1-Feb-11 3:23am    
My Vote of 5: For the effort already put and about to be put. :)

Steps as above (Answer 1) - however, you could use a ListView instead of a listbox. Set the "view" property to "details" though!

Add a ListViewItem for the e.g. ID and to that ListViewItem, add a subitem for the Address.
Hope I'm not too wide of the mark here!
 
Share this answer
 
By reading your requirement i guess following should be the steps:

1) Use textbox (where user is typing the address) text change event to match address with Regular Expression with value stored in database table.

2) Bind the Listbox with fields ID (item value) and Address (item text), for all matching rows from database. (ID being the unique identifier of the row)

3) When user clicks on listbox item, get the SelectedItemValue and query back in database to get further details.

Hope this helps :)
 
Share this answer
 
Comments
skunkhead 1-Feb-11 4:07am    
thanks Amit,

Your point 1 & 3 looks good, but..

2) I tried to do using ListBox, but it isn't very intuitive because it contains objects instead of something like ListItem and just able to add the text that will be shown on the list. The value, i'm not able bind to the listbox.

I guess you were mentioning this,

listbox.DisplayMember = "";
listbox.ValueMember = "";

but this will set the value for the whole listbox itself not a particular item in the listbox.

More good ideas from experts like you really apppriciated :)
1. Use a ListView control with two columns: Id (hidden) and Address.
2. During search, use an SQL query with the LIKE operator to find all addresses that match the search text and load the results into the ListView control.
3. When an item is selected in the ListView control, use the value in the hidden Id column and query the database for the row with that specific Id.
4. Display the result in a set of text boxes (or whatever)
 
Share this answer
 
If you don't have any version constraint, you can use the below steps:
1. Presentaion Layer with DataGrid via XAML
2. Web service to perform CRUD(Create Read Update Delete) operations
3. Data access layer is thro LInQ to Entity with the data destination (Access)

Thro the above solution, you can build rapid, robust application with high flexibility.
 
Share this answer
 

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



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