I'm working from a code base I downloaded from a repository, and it is likely that I'm missing a system or local setting.
In Web.Config, I have this connection string:
<add name="Context"
connectionString="Data Source=InstanceName;
Initial Catalog=MyProduct;
Integrated Security=True;
Connect Timeout=15;
Encrypt=False;
TrustServerCertificate=False"
providerName="System.Data.SqlClient" />
(indentation mine)
Normally I would have expected the Data Source
to be \\ComputerName\InstanceName
or at least .\InstanceName
if the SQL Server is on the same host. But here, nothing. The initially uploaded project had a local database, on the developer's machine. I can get the connection to work if I add .\
, but I don't understand how only specifying the instance name can work. So, how can it?
The instance name is needed only if you want to connect to a named instance.
If your install of Sql Server hasn't created a named instance then the default for the instance is MSSQLSERVER
and you DON'T need to specify that part on the connection string.
However, the computer name part is required but it could be expressed in various form
More info on the Data Source key could be found on MSDN docs for ConnectionString
Could it be that the InstanceName is the name of an ODBC Data Source that already has the target server configured, and the other employees have a corresponding ODBC data source set up?
The other option is that the connectionstring is modified before being passed to a data connector, so "MyMachineName" + connectionstring is happening somewhere (perhaps to separate production and development environments?
Also, double check the App_Data folder to make sure some sort of file-based database isn't being accessed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With