View Full Version : What 's Wrong with this Code

07-10-2006, 09:40 AM
I'm Trying this code to switch the user group , so this code select users with groups only if the user doesn't have a group or does'nt exist redirect it to another page
Her is my code please check it

sql="select * from users,groups where users.user_id='"&id2&"' and users.group_id=groups.g_group_id"
set rs=conn.Execute(sql)
if rs.eof or rs("group_id")=null then
dim group

end ifand It gives me this error message
Error Type:
Exception occurred.
Many Thax:)

07-31-2006, 04:44 PM
you have a comma here instead of a period(full stop)
sql="select * from users,groups where users.user

08-02-2006, 01:12 PM

Can you explain the usage of

or rs("group_id")=null

statement while checking the condition? what is the need for that statement. Since the SQL will return only records from users and groups table that have a proper master-detail relationship.

If you have implemented the referential integrity constraints on your DB then there is very less chance of getting some orphan records too.

My point is in your SQL statment you've used two conditions

The first the userid field of users table must have the value stored in id2 variable.

The second one is it will check the groupid field of users table to groupid field of groups table. Then how a groupid value which is null will come.

When i removed that line the code worked correctly.

Hope this will help you


Code Exploiter