Here is my Code:
private void button2_Click(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection("Data Source=DESKTOP-BPRGRPB/SQLEXPRESS;Initial Catalog=Test;Integrated Security=True");
connection.Open();
MessageBox.Show("connected!");
}
I pulled the ConnectionString from the Server Explorer in VS2022. The following Error occurs after the ConnectionTimeout.
Microsoft.Data.SqlClient.SqlException: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'
Inner Exception: Win32Exception: The network name cannot be found.
This is my first time using a database so I have no idea what I am doing. I just wanted to get it a shot and see if I could get a connection to a database running. I, also, tried using a SQLConnectionStringbuilder to make a Connection String with no luck.
I checked to setting is SQL Server Management Studio and remote connections are allowed.
Thanks for any help.