Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys
I wrote a program in VB.NET
I got this error when i run the program
"Login failed for user ''. The user is not associated with a trusted SQL Server connection."

How can solve this error ???
please help me.
Posted

The person running the app doesn't have permissions to the SQL database and your connection string mentions Trusted Connection.

Either change the connection string to remove Trusted Connection and supply a valid username and password to the database or add the userId to the database's Security (domain-based networks only!)

I would HIGHLY suggest reading up on SQL Server security before proceeding though...
 
Share this answer
 
Guy's I've this code

VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim cnStrBuilder As New SqlConnectionStringBuilder()
       cnStrBuilder.InitialCatalog = "FirstSQLDB"
       cnStrBuilder.DataSource = "WIN-H08I7LJ7JEA\SQLEXPRESS"
       cnStrBuilder.ConnectTimeout = 30
       Dim cn As New SqlConnection()
       cn.ConnectionString = cnStrBuilder.ConnectionString
       cn.Open()
       Dim strSQL As String = "Select * From Employee_Info"
       Dim myCommand As New SqlCommand(strSQL, cn)
       Dim reader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
       TextBox1.Text = reader(1).ToString()
   End Sub


Evey tome I run it, I got the same error
"Login failed for user ''. The user is not associated with a trusted SQL Server connection."

I did a lot of things but i doesn't work
Please Help ??
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900