UPDATED FOR CLARIFICATION
I posted a similar question a while back found here which used Matlab (and Matlab GUI).
However, now I am trying to do the same thing, but implemented through a Windows Form, C#, and a local, static database file which has been populated with data already.
The data in the database is as follows:
Compound_ID Component1 Component2 Component3 Value
int string string string int
with ~24,000 rows of data.
The first column “Compound_ID” is the primary key. The next three columns, “Component1”, “Component2”, and “Component3”, contain one component each from a set of ~100 possible components. Each compound is made up of 3 different components from the set of 100. Order of components doesn’t matter, so the Compounds are combinations (as distinct from permutations) of 3 components. Example:
Compound_ID Component1 Component2 Component3 Value
1456 a b c 10
1457 a b m 50
1458 a c g 25
etc. From this example, we know that there will never be another compound in the DB that is “a g c” or any other permutation thereof, since order doesn’t matter (A list of 100 values will generate ~161,000 combinations of 3, but almost 1,000,000 permutations of 3).
The user will select some number of components (with a list of checkboxes or a spreadsheet) on the Windows Form. They will press a button on the form. The button will call a method to find all of the Compounds listed in the database which can be made from the list of components the user has selected. This data will be displayed in a dataGridView on the same form.
One way it might be done (similar to the Matlab solution described by another user in my previous post): Generate 3 logical arrays, one for each column, where “1” represents the rows containing one of the 15 components. Add the columns together, and only those rows which have a value of “3” are the rows I am looking for. Then build a new table containing those rows, and display in datagridview. Any tips on how this code might look would be helpful.
I am going to give some of the solutions already provided a try. This would involve figuring out a way to call an SQL Query from C#, which I am told I can look up, and an example has already been provided.
Thanks to everyone for your help. This is a solely independent project born of curiosity, so it is not serious business, I am just trying to figure it out. I am relatively new to C# (and definitely SQL Queries), so please excuse my ignorance. Point me to sources with a little explanation if that would be a better use of everyone’s time.
I think this is it:
UPDATE
database table values
So if you choose Helium, Oxygen, Nitrogen, Barium, Chromium, Calcium and Uranium, you should get rows with PKIDs 1 and 10, and that’s it. Right?
I used Access because we don’t use SQL Server here, but you can swap out the ODBC object for SQL objects and it works.