Error: 18456, Severity: 14, State: 6.

im trying to create a connection to ms sql 2005 express edition. but it gives me the following error. Ms SQL installed on my local computer and im logged in as Administrator. I checked the connection with ODBC and it makes the connection successfully:

SQL Native Server
Microsoft SQL Native Client Version 09.00.3042

Data Source Name: Test1
Data Source Description:
Use Integrated Security: Yes
Database: (Default)
Language: (Default)
Data Encryption: No
Trust Server Certificate: No
Multiple Active Result Sets(MARS): No
Translate Character Data: Yes
Log Long Running Queries: No
Log Driver Statistics: No
Use Regional Settings: No
Use ANSI Quoted Identifiers: Yes
Use ANSI Null, Paddings and Warnings: Yes

im using the following code but it didn't connect me to sql server. Error says :
Login failed for user 'SVSWAQAR\Administrator'.

Below is my code:
Dim conn As New SqlConnection("Server=SVSWAQAR\SQLEXPRESS;User id=SVSWAQAR\Administrator;Password=S0lar1s;Database=master;")
Catch ex As Exception
    TextBox1.Text = ex.Message.ToString
End Try

I checked the logerror file and it gives me the following information:
2008-01-31 12:15:45.68 Logon       Error: 18456, Severity: 14, State: 6.
2008-01-31 12:15:45.68 Logon       Login failed for user 'SVSWAQAR\Administrator'. [CLIENT:]

Please help me fixing this problem.
Best Regards
Who is Participating?
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.

Did you create a SQL login SVSWAQAR\Administrator or are you attempting to pass alternate windows credentials into a connectionstring other than the current logged in user?
shwaqar82Author Commented:
this is windows credentials. and i can see that in sql server management tool:
SVSWAQAR\SQLEXPRESS(SQL Server...) > Security > Logins
I also addes it under Credentials category
you can't spoof windows credentials.  If you want windows credentials, it is always the current user so use the option Trusted_Connection=YES.

Dim conn As New SqlConnection("Server=SVSWAQAR\SQLEXPRESS;Trusted_Connection=Yes;Database=master;")

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
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

shwaqar82Author Commented:
that fix my problem ...can you elaborate your answer little more please. And also i need you to explain me how can i use sql credentials. Just want to mention you that you already got your point but a little more help make me feel good

Best Regards
SQL credentials use the syntax you had listed with the UserId/Password in the connection string.  It allows you to specify logins specific to the application.  But you want to use Windows authentication where you can which in this case you obviously do.  It allows the user running the app to have a set of privileges but not the application.

About the part where you can't specify alternate windows credentials..... connection is always going to authenticate in the context of the user running the application.  I don't know how this would translate in vista or xp if you choose the "Run As" option but I would imagine that it would take the context of the "AS" user.
shwaqar82Author Commented:
the funny part is i added the credentials for SQL Server as SVSWAQAR\Administrator but it does not picking it up.
did you add a windows or SQL account?  look in master..sysxlogins.  The \ makes it windows i'm pretty sure.
shwaqar82Author Commented:
Dim conn As New SqlConnection("Server=SV62578\SQLEXPRESS;Trusted_Connection=Yes;Database=master;")

the above connection works properly . my question is how can i make an sql connection.
You may have installed it in Windows Authentication mode only (default).  If not...
sp_addlogin [ @loginame = ] 'login' 
    [ , [ @passwd = ] 'password' ] 
    [ , [ @defdb = ] 'database' ] 
    [ , [ @deflanguage = ] 'language' ] 
    [ , [ @sid = ] sid ] 
    [ , [ @encryptopt= ] 'encryption_option' ] 

Open in new window

shwaqar82Author Commented:
okie thanks this is much better for me ...thanks alot for quickly slove my problem
We try!
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
Microsoft SQL Server 2005

From novice to tech pro — start learning today.