SYBASE-  Cannot open the database

vijadon
vijadon used Ask the Experts™
on
I am unable to connect to the database :
Getting the following error:

isql -Ssybcpsuat -UcustomerOP2 -Pcustomerop2

Msg 10351, Level 14, State 1:
Server 'sybcpsuat':
Server user id 6 is not a valid user in database 'customer'
Msg 4001, Level 11, State 1:
Server 'sybcpsuat':
Cannot open default database 'customer'.

Thank you for your help.

Vinai

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Well, the error message is quite descriptive - login customerOP2 has no user set in database customer and it seems, that this database customer is set up as default database for login customerOP2. However, you can should be still able to connect to the server, you can use just databases, where this login has user or there's a guest user account.

If you are DBA - add user to the database (using sp_adduser), if you are not DBA, ask your DBA to do it.

Author

Commented:
I tried to add the user to the database and this is what I get:
Server Message:  Number  17331, Severity  16
Server 'sybcpsstage', Procedure 'sp_adduser', Line 254:
User already has a login under a different name.
(1 row affected)
(return status = 1)


I am new to sybase,  I appreciate your help.

thank you
Vinai
sp_helpuser will show you list of users defined in database along with their logins. It seems, like you have user with name customerOP2 in database customer, but this user is not bound to customerOP2 login. So you can either create user with different name for customerOP2 login or "rebind" user customerOP2 with customerOP2 login (but this will probably block access to this database for login currently bound to customerOP2 user)
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Author

Commented:
Can you also give me the syntax for the first solution ,I already created two users  till now and both do not work.

The reason I am doing this is I already have a existing user ehich is giving me this problem.

thank you
exec sp_adduser loginname, username [, groupname]

you have to execute it in customer database (hope you have some login, that you can use to get to this database).

So, if you want to create user customerOP2X for login customerOP2 use:
exec sp_adduser customerOP2, customerOP2X

by default, new user will be in public group, if you want him to be in other grouo, use:
exec sp_adduser customerOP2, customerOP2X, yourgroupname

Author

Commented:
When I run this stmt

exec sp_adduser customerOP2, customerOP2X

it gives me this error:
Server Message:  Number  17331, Severity  16
Server 'sybcpsstage', Procedure 'sp_adduser', Line 254:
User already has a login under a different name.
(1 row affected)
(return status = 1)

Do not understand as to what to do, if I try to drop the user it does not let me drop the user.

thank you for your help.

Could you post output of sp_helpuser ?

Author

Commented:
Users_name        ID_in_db    Group_name        Login_name        
----------        ----------- ----------        ----------        
customerOP                  3 public            cust_OP          
customerUSR                 4 public            customerOP2      
dbo                         1 public            customerDBO      

OK, login customerOP2 is asociated with user customerUSR. Does your original problem still exist ? Do you still get that error "Server user id 6 is not a valid user in database 'customer'" ?

Author

Commented:

When I connect as  customerOP2 and try to run a select statment it gives me the error:

Server Message:  Number  10330, Severity  14
Server 'sybcpsstage', Line 1:
SELECT permission denied on object Customer, database customer, owner dbo

thanks for all your help
Vinai
Well, it seems, that your original problem is solved. Now you have problem with permissions on table Customer.

If you have DBA, ask him to set up premissions, so you can access tables you need. If you are DBA, you should spend some time reading Sybase System Administration Guide - http://sybooks.sybase.com/onlinebooks/group-as/asg1250e/sag. Chapter 11 - Managing User Permissions is what you need just now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial