Click here to Skip to main content
15,908,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir/Madam

I have created a C# Project with couple of Forms inside this project. In one particular form (lets say Form1) I have 10 Buttons. I also created a Access 2007 DataBase and inside this database I have a table with 10 records.

Now my question is:

Is there a possibility to call these 10 database records dynamically from Form1 (but not one-by-one).

What I mean is I dont want to create for every button event an opening db conn, exec query, and so on. So basically what I want is: the 10 buttons that I have in my form to create one sql query (lest say like an array query) so when I click button1 to get the rocord1 from db table and displayit in to my list view, same for button2, button3 and so on...

Basically what I want is, when Form1 Loads (where inside this form are 10 buttons) to create an SQL Query, get those 10 records from database, and each button I click I want that db record to match the corresponding button and display that record on my list view.


Kind Regards


Agron
Posted

1 solution

Have you tried anything?

If you would simply select the records with an sql statement like select * from myTable order by button_id then you will get a recordset with all the records. You could simply get the row you want because all the rows are available in the recordset.

http://www.sqlselect.org/cs-sql-select-access.html[^]

Good luck!
 
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