Problem To Search and Save Database

zubairanxari

New member
Joined
Mar 19, 2022
Messages
1
Programming Experience
Beginner
Hi Seniors! I'm New Here and beginners in MVC .NET C#
I Need Information for My Problem.
I have two columns in database the names are like
First Name & Last Name and both are text box in my web

In these columns I retrieve data from database if database has it. in other way if database have no name it will add in database and in next turn show it in my text box.

for more info like Google Search when I type one keyword he suggest me the name and if this name is available in my database if this name not available my this text box add directly from there and next turn it aging show on key press
in two picture first one suggested me
and second is adding in the same text box to database
Is it Possible????? if possible kindly help me Thanks!
 

Attachments

  • 1.PNG
    1.PNG
    14.3 KB · Views: 13
  • 2.PNG
    2.PNG
    11.6 KB · Views: 14
What you are looking for is called "auto complete". Most of that is implemented using JavaScript which will make AJAX calls back to your controller, and your controller responds with the suggested values.

As cool as your UI sounds where names are added into the database automatically if it doesn't exist in the database, I highly suggest that you think this through carefully. What if someone simply misspelled a "John" as "Jogn"? Are going to add "Jogn" as a new first name? Also think carefully about how you will detect if a person really meant to type in "Jo", or if they are simply a slow typer and they still hunting and pecking on the keyboard to find the the other letters, or if they accidentally shifted focus to another control.
 
As cool as your UI sounds where names are added into the database automatically if it doesn't exist in the database, I highly suggest that you think this through carefully. What if someone simply misspelled a "John" as "Jogn"? Are going to add "Jogn" as a new first name? Also think carefully about how you will detect if a person really meant to type in "Jo", or if they are simply a slow typer and they still hunting and pecking on the keyboard to find the the other letters, or if they accidentally shifted focus to another control.
I get the feeling that the OP was not talking about anything the user enters but only what the user saves, e.g. if the database is empty and the user saves a record with the name "John", "John" will become an auto-complete entry in the future. We do that in a number of our applications but not for the same exact field. For instance, we may have an Organisation table with an OrganisationName column. We won't use auto-complete on the corresponding field when a new Organisation is added but we will use it on the Organisation when a new User is added. We use auto-complete in situations like that where the list is unfeasibly long to display in a static drop-down list.
 
I guess I misinterpreted this:
if this name not available my this text box add directly from there

to mean to automatically save if the value was not found in the database.
 
Back
Top Bottom