Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am a student and developing a simple assignment - windows form application in visual studio 2010.

The application is suppose to construct formulas as per user requirement.

The process: It has to pick data from columns of Microsoft Access database and the user should be able to pick the data by column name like we do in a drop down menu. and create reusable formulas in it ( configure it once and can change it again). followings are column titles from database that can be picked for example.


Col -1 : Marks in Maths Col -2 : Total Marks in Maths Col -3 : Marks in science Col -4 : Total marks in science

Finally we should be able to construct any formula in the UI like

(Col 1 + Col 3 ) / ( col 2 + col 4) = Formula 1

once this is formula is set saved and a name is assigned to it by user. he/she can use the formula and results shall appear in a window below.

i.e He would be able to calculate his desired figures (formula) by only manipulating underlying data on the UI layer....choose the data for a period and apply the formula and get the answer


It looks like I have to create an app where rules are set through UI....... this means no stored procedures are required in SQL.... please suggest the right approach.

share|improve this question

closed as not a real question by gnat, Walter, Matthieu, Ryathal, Dynamic Sep 20 '12 at 10:27

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

i m using c# not vba –  BriskLabs Pakistan Sep 9 '12 at 15:27

3 Answers 3

Two words: Dynamic SQL

Extra Credit for Protecting against SQL Injection

share|improve this answer
hey sorry didnt get it.... what does this suppose to mean... –  BriskLabs Pakistan Sep 9 '12 at 15:33
well although that did not help and but was a good joke to lighten the mood :D –  BriskLabs Pakistan Sep 9 '12 at 15:36
Take your parameters, Build your select statement, then execute it. –  Morons Sep 9 '12 at 15:40
Look at it this way, SQL is just a string.. You can build a string. –  Morons Sep 9 '12 at 15:41

I agree with the spirit of Morons' answer, but disagree with the implementation.

As I see it, you have four primary tasks/challenges:

  1. Parse the user's input.
  2. Validate the user's input.
  3. Compute the validated formula.
  4. Write glue code that hooks into the Access database.

Here are some thoughts:

  1. Consider making the surface area of your UI small so that your users can fall into the pit of success.
  2. Consider the Builder pattern to assemble the equations on the server-side.
  3. When computing each formula's result, your choice of data structure will be critical. My first inclination would be to use a stack, but many people offered opinions on this topic on Stackoverflow.
share|improve this answer

from what I could understand from the question, I would create a select statement to pull the column names out and put them into drop down boxes so that I can pick which columns that I want.

then you would have to figure out a way to do the math manipulation.
I would probably think of the possible ways that the user will want to use the data and then create little snippets of code that create the backside code to do each math function so that you can build the command as the user inputs the data.

I know I am kind of being vague, but I don't want to give you all the answers. :)

I am willing to elaborate a little bit more if you really need it

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.