A
Arpan
Suppose an ASP application which retrieves data from a SQL Server
database table is accessed by 100 users. Each of the users have a
password. Assume that the DB table has 25 columns [Column1....Column25]
& the passwords of 3 users are 'A1', 'B2', 'C3' (excluding the quotes).
What the application should do is if the password is 'A1', then that
user should be displayed the records of the columns Column1, Column7,
Column16, Column20 & Column25 only. If the password is 'B2', then that
user should be displayed the records of the columns Column3, Column6,
Column 15 & Column 17. If the password is 'C3', then that user should
be displayed the records of the columns Column2, Column8, Column11,
Column17 & Column23, so on & so forth.
This can be implemented in this way:
----------------------------------------
If(strPassword="A1") Then
'retrieve Column1, Column7, Column16, Column20 & Column25
ElseIf(strPassword="B2") Then
'retrieve Column3, Column6, Column 15 & Column 17
ElseIf(strPassword="C3") Then
'retrieve Column2, Column8, Column11, Column17 & Column23
................
................
................
................
................
End If
----------------------------------------
This means that there will be 100 If....Else statements which obviously
will not only be an inefficient approach but also a highly cumbersome &
tedious one. How can this be implemented more efficiently?
Please note that all the passwords will be stored in a different DB
table.
Somewhat weird, I guess but that's what my client wants!!
Thanks,
Arpan
database table is accessed by 100 users. Each of the users have a
password. Assume that the DB table has 25 columns [Column1....Column25]
& the passwords of 3 users are 'A1', 'B2', 'C3' (excluding the quotes).
What the application should do is if the password is 'A1', then that
user should be displayed the records of the columns Column1, Column7,
Column16, Column20 & Column25 only. If the password is 'B2', then that
user should be displayed the records of the columns Column3, Column6,
Column 15 & Column 17. If the password is 'C3', then that user should
be displayed the records of the columns Column2, Column8, Column11,
Column17 & Column23, so on & so forth.
This can be implemented in this way:
----------------------------------------
If(strPassword="A1") Then
'retrieve Column1, Column7, Column16, Column20 & Column25
ElseIf(strPassword="B2") Then
'retrieve Column3, Column6, Column 15 & Column 17
ElseIf(strPassword="C3") Then
'retrieve Column2, Column8, Column11, Column17 & Column23
................
................
................
................
................
End If
----------------------------------------
This means that there will be 100 If....Else statements which obviously
will not only be an inefficient approach but also a highly cumbersome &
tedious one. How can this be implemented more efficiently?
Please note that all the passwords will be stored in a different DB
table.
Somewhat weird, I guess but that's what my client wants!!
Thanks,
Arpan