As per title, this simple code should create a ConnectionString for SqlServer:
Dim ConnectionBuilder As New SqlConnectionStringBuilder
With ConnectionBuilder
.ApplicationName = "My App Name"
.ConnectionString = $"Server={SQLServerNameAndIstance};Database={TargetDB}"
.UserID = ConnectionUser
.Password = ConnectionPassword
.Pooling = True
.WorkstationID = ClientID
End With
ConnectionString = ConnectionBuilder.ToString
However, in SSMS I see the default name ".Net Sql Client Data Provider": if I set as below
.ConnectionString = $"Server={SQLServerNameAndIstance};Database={TargetDB};Application Name=My App Name"
all works as expected. What's wrong with that code? Or what's wrong with SqlConnectionStringBuilder?
The best way to solve that problem is by using a .udl file, where you can configure the SQL parameters to make the connection and at the end you'll have a view that will give you all extra parameters and you can compare with the ones you wrote in you code.
Just create on your desktop a text file called test.txt, if you cannot see the extension .txt you need to open a window explorer > go to See/View > Options > See/View > and uncheck the "Hide files with known extensions" (or similar to that).
Then go to your test.txt file and change to test.udl, open the file and configure the values to make the connection you want. After a successful connection, you can go to the last tab ALL and compare all parameters with the ones you put on your code.