trying to create a sql login and a user for a database but its not connecting

i am trying to create a login and a user for my sql server i am later going to use these in my connection string but for some reason it does not seems to work. i tried :



IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'admin ')
    CREATE USER [admin ] FOR LOGIN [admin ]
    EXEC sp_addrolemember N'db_owner', N'admin'

Open in new window

the above code creates the login and user but i can't use those credentials to connect to the sql server.

i also tried

-- Create a new SQL Server Login
exec sp_addlogin @loginame = 'admin', @passwd = 'Pa55w0rd'
-- Grant the SQL login access to your database. 
-- Create a database user called WebAppUser to which the login is associated 
exec sp_grantdbaccess 'admin'

Open in new window


that didnt work either any suggestions on how i can fix this issue, i even tried creating a login and user via gui that didnt work either.

i am using a sql server 2008 express edition
Aravind RanganathanWindows Application DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dmitri FarafontovLinux Systems AdminCommented:
What error message that you get when attempting to connect?
Aravind RanganathanWindows Application DeveloperAuthor Commented:
this is the error i am getting.
SolarWinds® VoIP and Network Quality Manager(VNQM)

WAN and VoIP monitoring tools that can help with troubleshooting via an intuitive web interface. Review quality of service data, including jitter, latency, packet loss, and MOS. Troubleshoot call performance and correlate call issues with WAN performance for Cisco and Avaya calls

Aravind RanganathanWindows Application DeveloperAuthor Commented:
i went through those articles still not working, still getting the same error
Dmitri FarafontovLinux Systems AdminCommented:
Shaun VermaakTechnical SpecialistCommented:
Change your server authentication to SQL Server and Windows Authentication mode
Vitor MontalvãoMSSQL Senior EngineerCommented:
Are you're sure you've created the login in the correct SQL Server instance?
Or if you're trying to connect to the same SQL Server instance where the user has been created?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
Aravind, a feedback will be appreciated.
Aravind RanganathanWindows Application DeveloperAuthor Commented:
idk what the issue was my manager created a username and password on the server itself.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.