This is my connection string:
private static string connectionString = @"Data Source=DESKTOP-NAME\PRODUCTDB;User ID=USER;Password=********;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
SqlConnection connection;
This is my function:
public void checkForProduct(Int64 Scanned_EAN)
{
using (connection = new SqlConnection(connectionString))
{
// Open the connection, so we can perform SQL commands
connection.Open();
}
}
If I try to run this, I get the cannot connect to SQL Server browser. I have searched for 10 hours today and I can't seem to find the answer. The database is running, the server browser is running, I have let them through firewall, forwarded TCP, and UDP port for SQL. I am using SSMS, and I have managed to connect to the database using the server explorer in Visual Studio. But I can't connect via code.