Hey all I am trying to connect to my SQL Server that I log into using my windows authentication user name and password. However, when I use that information in the code below it tells me that it can not connect…
Dim connetionString As String
Dim cnn As SqlConnection
connetionString = "Data Source=MSSQLPROD;Initial Catalog=MS435_PROD;User ID=me.here;Password=mypassword;"
cnn = New SqlConnection(connetionString)
Try
cnn.Open()
MsgBox("Connection Open ! ")
cnn.Close()
Catch ex As Exception
MsgBox("Can not open connection ! ")
End Try
You are using SQL Server authentication when you specify a user name and password in the connection string. Remove the user name and password and include:
That will cause the connection to use the Windows authentication of the context executing the code.