I search on the net in order to find the solution but all of them refer to the situation in which you must make connection with database that already exists.
In my case, I must make a connection with the server (localhost/SQLEXPRESS) and not create any database yet.
Just the connection with server.
Then, if connection is made, I will create database if necessary.
I get error on conn.Open() I tried:
var conn = new SqlConnection("Server=localhost\\SQLEXPRESS;Integrated Security=SSPI")
but as I said it doesn't work.
EDIT:
Ok, I understood that I must connect to some default database. Now I edited my connection string like this:
"Server=localhost\\SQLEXPRESS;Integrated Security=SSPI;database=master"
But I get error:
System.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: TCP Provider, error: 25 - Connection string is not valid)'