Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using a text box name invoice in window forms which is connected with database. . . .now i want that if the value enter is present in database then it collect all information regarding that value and fill other text boxes but if the value is not present then manually fill all text boxes and then save it. . . . . . .now i have a problem i don't have any idea how to do it. . . .plzzzz help me out
Posted

I suggest you walk through this tutorial to learn about how to creat a windows application using C#.NET, ADO.NET and MS Access[^]
 
Share this answer
 
v2
Ok Here is what you can do
If Textbox value is in Database fill out the remaining Text box. If value is not present in DB show a pop up asking user to fill the details.

Dataset dsresult = Checkinoyour Database query
if dsresult has rows fill the other textboxes
if dsresult doesn't have rows, show a pop asking to fill the textboxes
As simple as that.
 
Share this answer
 
I had a project in which I had to make almost the same.

In the following example, a text file is used as database and a textbox1 is the main textbox.

C#
if(textBox1.Text == File.ReadAllLines(@"C:/database.txt")//if your textbox has a line from database...
{
     MessageBox.Show("One match found: " + textBox1.Text); //Show messageBox

}else //if the textbox has no match with a line from database...
     {
     MessageBox.Show("No match found! Added to database instead."); //Show messageBox
     StreamWriter sw = new StreamWriter(@"C:/database.txt"); //Create StreamWriter to modify database
     sw.WriteLine(textBox1.Text); //Add the new value to database
     sw.Close(); //Close the streamWriter
}


Hope this helps! Cheers - CCB
 
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