Can't open SQLConnection using SQL Authentication

fieldb1
fieldb1 used Ask the Experts™
on
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!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

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

Author

Commented:
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.
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
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.

Commented:
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.
Check user mappings first.

Author

Commented:
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.

Author

Commented:
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!

Author

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

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