0

I am developing a memory matchgame which is supposed to get words and their translations from access database which has 3 columns ID, word and translation. The program has 52 buttons. What i want is that on load the program should assign these words and translations at random to my 52 buttons Text.. I really don't know how to accomplish this

I have managed to connect to the database using a connectionstring

public partial class Form1 : Form
{
    private OleDbConnection connection = new OleDbConnection();
    Random random = new Random();

    public Form1()
    {
        InitializeComponent();
        AssignToButtons();
        connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\DZINGO\Documents\Visual Studio 2015\Projects\new game\matchwords.accdb;
        Persist Security Info=False;";
    }
}
  • If your problem is randomizing your retrieved data maybe [Correctly using LINQ to shuffle a deck](https://stackoverflow.com/q/19201489/205233) can give you an idea. – Filburt May 01 '19 at 10:13
  • List buttons = new List() { "cow","ngombe","mouse","man""cow","ngombe","mouse","man"}; – angoni6 May 01 '19 at 10:27
  • private void AssignToButtons() { Button button; int randomNumber; for (int i=0; i – angoni6 May 01 '19 at 10:29
  • what i want is that button list to be populated from a database. as it is now it is populated using the listed words in quotes – angoni6 May 01 '19 at 10:30
  • The first thing you do is remove this: `private OleDbConnection connection = new OleDbConnection();`. Connections are opened in place (when you need to retrieve or store data) and closed right after. With MS-Acces and ACE more than others. If you don't, you app will classify half way between a turtle and a fossil. At least, provide the query that should fetch the data. Use a DataAdapter to fill a DataTable. Then you need a support class that generates and keeps track of the objects you use to present the data (the coupled lists of terms and the Controls where these strings are shown) – Jimi May 01 '19 at 12:42

0 Answers0