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

Hi
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:
Server: SVSWAQAR\SQLEXPRESS
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:
Try
Dim conn As New SqlConnection("Server=SVSWAQAR\SQLEXPRESS;User id=SVSWAQAR\Administrator;Password=S0lar1s;Database=master;")
conn.Open()
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: 172.16.6.85]

Please help me fixing this problem.
Best Regards
Shaukat
shwaqar82Asked:
Who is Participating?
 
BrandonGalderisiConnect With a Mentor Commented:
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;")
0
 
BrandonGalderisiCommented:
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?
0
 
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
Shaukat
0
 
BrandonGalderisiCommented:
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.
0
 
shwaqar82Author Commented:
the funny part is i added the credentials for SQL Server as SVSWAQAR\Administrator but it does not picking it up.
0
 
BrandonGalderisiCommented:
did you add a windows or SQL account?  look in master..sysxlogins.  The \ makes it windows i'm pretty sure.
0
 
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.
0
 
BrandonGalderisiCommented:
You may have installed it in Windows Authentication mode only (default).  If not...

http://msdn2.microsoft.com/en-us/library/ms173768.aspx
sp_addlogin [ @loginame = ] 'login' 
    [ , [ @passwd = ] 'password' ] 
    [ , [ @defdb = ] 'database' ] 
    [ , [ @deflanguage = ] 'language' ] 
    [ , [ @sid = ] sid ] 
    [ , [ @encryptopt= ] 'encryption_option' ] 

Open in new window

0
 
shwaqar82Author Commented:
okie thanks this is much better for me ...thanks alot for quickly slove my problem
0
 
BrandonGalderisiCommented:
We try!
0
All Courses

From novice to tech pro — start learning today.