Link to home
Start Free TrialLog in
Avatar of fieldb1
fieldb1Flag for United States of America

asked on

Can't open SQLConnection using SQL Authentication

I have a virtual server on a home machine. The network is a workgroup, not a domain, so I use  SQL Authentication. When I run the following code:

Try
  blah blah
   Connection.Open()
  blah blah

I get the following message:

Cannot open database requested by login. Unable to login. Login failed for user "mylogin".

Here is my ConnectionString:

Dim ConnectionString As String = "Data Source=VirtualServer; Initial Catalog=Service History; User ID=myUserID; Password=myPassword"

Thanks in advance for any assistance!
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Here are alternate connection strings : http://www.connectionstrings.com/sql-server-2008  Have you enabled remote TCP/IP connections in the server?
Avatar of fieldb1

ASKER

Yes, the server is set up to allow remote connections. To test it, I just logged on with remote desktop.      I have tried different connection strings as well. I think it has something to do with the security settings in SQL Server. I'm used to using windows authentication, unfortunately.

I see that my UserID is not one of the users under the security folder for the database I'm trying to connect to, although it does exist in the main security folder under Logins. When I attempt to add the UserID to the database in question, it says that the UserID already exists. I must be missing something in these security settings.
I don't remember and can't look that up at the moment.  If no else helps you soon, click on "Request Attention" to get some others to look at your question.  I think we answered this yesterday on another question.
Does the particular login exists in the server. If yes, what is its server level role? If it is not sysadmin on the server, is there user created and databases level roles assigned for the login to the problematic database which he is not able to access?
Probably user has no rights assigned.
ASKER CERTIFIED SOLUTION
Avatar of no worries :-) no nothing
no worries :-) no nothing
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fieldb1

ASKER

Yes, it's clear that the user mappings are not correct, but I am unable to change anything. I can't even delete the login. I have logged in with the sa account, but cannot delete the login (due to the fact that it is a db owner in some instances),  nor transfer the dbowner role. Very frustrating.
Avatar of fieldb1

ASKER

Ok, got it working. I had to freakin delete the databases for which the login was db owner, then delete the login, then recreate everything from scratch. But atleast my app is connecting and executing commands now. Thanks!
Avatar of fieldb1

ASKER

It was spot on, but the issue was a little more complex. Thanks!