querying a Acces DataBase
-
I posted this question before bit I think I may have asked it wrong. I want to set up a program to query 1 field in the DB by pressing a button and then displaying the results in a listbox. At which point I can click in the listbox and display the record in the textboxes. BINARY
-
I posted this question before bit I think I may have asked it wrong. I want to set up a program to query 1 field in the DB by pressing a button and then displaying the results in a listbox. At which point I can click in the listbox and display the record in the textboxes. BINARY
if you are showing an ID field in your list you can use the id ( whenever is selected by the user) and select the record and then show its field in your text boxes. for example: using System.Data; using System.Data.OleDb; public void listbox_click(object sender,EventArgs e) { string selecet_string="SELECT * FROM MyTable WHERE id="+listbox.selectedItem.ToString(); DataSet ds=new DataSet(); OleDbDataAdapter adapter=new OleDbDataAdapter(select_string,cnn) //you should pass your own connection object. adapter.Fill(ds); //Then you can fill the text boxes textBox1.Text=ds.Tables[0].Rows[0][0].ToString(); //etc. }