A
APPDVLPR
Guest
I asked this on another site and I may as well have put my head in an oil-well burn-off fire. If this question generates as much displeasure and carries as much uselessness as was deemed on another site, I'm sorry in advance for asking. I'm just seeking advice.
I have a C# project built out with numerous namespaces and classes. Nothing remarkable. When I added classes to manage SQL connectivity and functions, the connectivity failed every time. It would get to the Open method and sit, eventually failing. I create a new project, insert the same code, and it works. Both projects on the same machine, same OS, same VS version, at the same time. I can take the code from the working project, paste it in Main() in the project that was failing to begin with, and it still fails with the same behavior. I placed it in Main() in case there could be namespace issues, or some sort of scope problem I'm missing.
My question, is, if I have checked all project settings, environment options, etc. ... cleared the bin and obj folders, cleaned, rebuilt ... what would cause one project to act as if the connections were blocked, but yet the identical code works fine in a new project???
The Exception message:
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)
The code:
string s = "Data Source=SERVER;Initial Catalog=DB;Trusted_Connection=True;";
SqlConnection oCN = new SqlConnection(s);
Continue reading...
I have a C# project built out with numerous namespaces and classes. Nothing remarkable. When I added classes to manage SQL connectivity and functions, the connectivity failed every time. It would get to the Open method and sit, eventually failing. I create a new project, insert the same code, and it works. Both projects on the same machine, same OS, same VS version, at the same time. I can take the code from the working project, paste it in Main() in the project that was failing to begin with, and it still fails with the same behavior. I placed it in Main() in case there could be namespace issues, or some sort of scope problem I'm missing.
My question, is, if I have checked all project settings, environment options, etc. ... cleared the bin and obj folders, cleaned, rebuilt ... what would cause one project to act as if the connections were blocked, but yet the identical code works fine in a new project???
The Exception message:
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)
The code:
string s = "Data Source=SERVER;Initial Catalog=DB;Trusted_Connection=True;";
SqlConnection oCN = new SqlConnection(s);
Continue reading...