Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection String with Windows Authentication Mode

I'm trying to test a simple connection to my database with VB.NET on my SQL Server 2008. The problem is my login is with Windows Authentication mode and I enter no password for it to connect to my SQL server.

How will a connection string in this case look like? This has blocked my progress for the whole day.

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim connetionString As String
        Dim connection As SqlConnection
        Dim i As Integer
        connetionString = "Data Source=PEDRAM-PC\PEDRAM;Initial Catalog=Test;User ID=Pedram-PC\Pedram;Password=bro"
        connection = New SqlConnection(connetionString)
        Try
            connection.Open()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class
like image 885
disasterkid Avatar asked Dec 06 '25 09:12

disasterkid


1 Answers

Add Integrated Security=SSPI instead of the username and password.

like image 77
SLaks Avatar answered Dec 08 '25 23:12

SLaks