CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2005
    Posts
    1

    Newbie needs expert advice

    I'm working on a Database project that has a person entering data in from a form, a Record of Service. I would like it so that when they type in the first part of the customers first or last name (seperate fields in the DB) that a list of options of customers comes up that matches what they are beginning to type in, they then can select the client 's name from the list, and the clients info will be filled in automatically.

    What is the best way to accomplish this?

    Thanks

  2. #2
    Join Date
    Jun 2005
    Posts
    2

    Re: Newbie needs expert advice

    Try using the comboBox control

  3. #3
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    Thumbs up Re: Newbie needs expert advice

    I guess its not a web-application. In that case it would be a bit tougher if not impossible.

    As for a window - form based application. The algo to achieve this goes as below:

    First - as suggested by Reyzidis use a combo-box control. An editable one.
    Then :
    1. On the Keypress event of the control - fire a query to your database (or read from a file) all the relevant first/last names with a like clause.
    2. You got the results, clean up your control and add up the found info.

    If at the form level you have any collection with all such info you would be searching for that matching sting among all items.

    Now the real issue that I think might cause trobles would be the state of the dropdown. I guess you would be needing a list to be shown (dropdown with an open state with some of the matching results showing). I am not quite sure if this is achievable with a dropdown. But I once used a text box and a list box control to achieve this.
    Whenever my list would be empty I would hide the list box and if results are there show the list box populated.

    I guess this might be of some help to you.

    All the best...Cheers,
    Exterminator.

  4. #4
    Join Date
    Mar 2005
    Location
    Chicago, IL
    Posts
    69

    Re: Newbie needs expert advice

    Use a dataset !!!

    If your datasize is not too big, preload your dataset with all the names from the database. Yo hold on dont gimme that look yet, I know this is ridiculous if your datasize if HUGE.. But if you have smaller data sizes, this works real cool . The amount of time taken to retrieve the matched names from memory will be amazingly small when compared to a round trip for to the database for every search.

    In essence you are caching the data u need so that u dont have to go to the database for info...

    happy coding ...
    Last edited by sudheeratwork; June 24th, 2005 at 12:21 PM.
    There has been an alarming increase in the number of things I know nothing about .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured