c# - How to populate list or array with values from access database -


i trying populate group of labels in c# windows form values in attribute (playername) in database have in access.

currently code have is:

oledbconnection connection = new oledbconnection(connection string here);  oledbcommand command = new oledbcommand(); command.connection = connection; command.commandtext = "select playername [totalplayername] team = 1 , sportid = " + form1.idnumber; 

i need list or array holds these values can use them populate labels, unaware of how this.

you need call executereader obtain data reader , loop through rows of result set this:

list<string> result = new list<string>();  using (var reader = command.executereader()) {     while (reader.read())     {         result.add(reader.getstring(0));     } } 

before this, don't forget open connection this:

connection.open(); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -