473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Need A Solution!

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

Sep 3 '05 #1
4 1300
>> How can this be implemented more efficiently?
Probably by normalizing your database, adding user / group tables and
assigning permissions to the users / groups.

Or, you could <barf>create 100 VIEWS for each of the users</barf> and do
your SELECT from the relevant VIEW.

Bob Lehmann

"Arpan" <ar******@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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

Sep 4 '05 #2
On 3 Sep 2005 16:37:37 -0700, "Arpan" <ar******@hotmail.com> wrote:
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).
You need a lesson in database design. A user is an entity (table). A
password is an attribute (column) of that entity. As would be a
UserName and a UserID (Primary Key). You now have a table with a
UserID, UserName and Password column.
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.
Same deal. You can bet each column is an attribute of something,
likely something different. Normalize your database, learn to use
authentication and learn to create an entity relationship diagram.
Your life will be a lot easier.
Please note that all the passwords will be stored in a different DB
table.
Please note that they shouldn't be.
Somewhat weird, I guess but that's what my client wants!!


Clients almost always want a working solution. Almost never would
thay decide on a seriously flawed implementation. If they did, and
forced it on a programmer, I'll bet 99% of programmers would turn down
the job.

Jeff
Sep 4 '05 #3
"Arpan" <ar******@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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.


How about another table that links your "condition" against the columns
that the user should be shown, something like this

Condition Field
A1 1
A1 7
A1 16
A1 20
A1 25
B2 3
B2 6
.... etc. ...

OK, so you have to /retrieve/ the fields for a given "condition" and
/build/ them up into a list that you can use in subsequent SQL, but it
does give you complete flexibility if (or rather, when) the columns
required /change/ over time.

NB: I say "condition" because using a single password to access each
"set" of fields is probably /not/ a good idea - it's amazing how fast
such "restricted" information moves around ... ;-)

HTH,
Phill W.
Sep 5 '05 #4
Thanks Bob, Jeff & Phill for your helpful suggestions.

Regards,

Arpan

Sep 5 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jani Yusef | last post by:
I have a HW problem stated as shown at the top of the solution. The thing is is that I am not 100% sure wtf constant memory means. Well, I think I do but I am confused. Does my solution use contant...
16
by: Joel Finkel | last post by:
Folks, I am confused as to how to implement the following solution. I have a series of processing steps, each of which contains similar features (forms, etc). Therefore, I create a base...
6
by: SP | last post by:
Hi, I want to add wait cursor code whenever page is post back. Page may be post back on my user control's or on change of dropdown or on click of any button on page. so is there any common...
2
by: moondaddy | last post by:
I'm building a small POS system which I'm going to license out and need to include credit card processing. I've build eCommerce sites before and custom coded CC processing for verisign, but that...
20
by: Tony | last post by:
I have a situation where I want to send data, but I have no need for a response. It seems to me that XMLHTTPRequest is the best way to send the data, but I don't need any response back from the...
23
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
1
by: VB Programmer | last post by:
Here's the scenario: 3 different pcs in a doctors office. 2 doctors with 2 seperate appointment calendars. All 3 pcs need to be able to see, real time, both doctors calendars and add, remove,...
10
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I...
25
by: Jon Slaughter | last post by:
I have some code that loads up some php/html files and does a few things to them and ultimately returns an html file with some php code in it. I then pass that file onto the user by using echo. Of...
7
by: MZ | last post by:
Hello, I have a webcam connected to the Internet. I can access the current static picture of the camera using an url link. It shows the picture with high resolution 1600x1200. I would like to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.