Start New Discussion within our Software Development Community

I have one field of the student in database and I have to pass two rules in it
i.e
Classes 1-9 will only have 1 book for 1 week and
Classes 10-12 will have 2 books for 2 weeks.
How can I do that?

With only one filed, you only can add the text explaining the rule, IE:
"Classes:1-9;Books:1;Weeks:1"
"Classes:10-12;Books:2;Weeks:2"
Here, I used the ; sign to separate concepts, I used the : sign to separate Identifiers from their values and used the - sign to separate the bounds.

You can create the filed content easely by concatenating the right words, separators and values.

You can 'decript' the field using the string Split() function 3 times. The first using the ; as separator to get the Keywords and the values, each in a separate string (3 strings in this case).

The second, for each KeywordAndValue string obtained, you can use the Split() function with the : as separator to obtain 2 strings: the Keyword and the Value

The third, for those kywords that have bounded values, you can use the Split() function again with the - as separator, to obtain the lower and upper values.

Hope this helps

This question has already been answered. Start a new discussion instead.