Question: I have a SQL Server 2008 installation on my local system, and the following code in C#, in .NET 4.5.

```
    private Boolean ConnectDatabase()
    {
        if( !this.IsInitialized())
        {
            return false;
        }
        else
        {
            try
            {
                String ConnectionString = "User ID=" + this.DatabaseUsername + ";" +
                                            "Password=" + this.DatabasePassword + ";" +
                                            "Server=" + this.DatabaseHost + "," + this.DatabasePort + ";" +
                                            "Database=" + this.DatabaseResource + ";";
                this.DatabaseConnection = new SqlConnection(ConnectionString);
                this.DatabaseConnection.Open();
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
    }

```

I can connect to the server in SSMS, but using the same credentials I am unable to get a connection in C#.

Connection string is as follows:

```
User ID=sa;Password=******;Server=CPUNAME\MSSQL,1433;Database=DBNAME;

```

Where `CPUName`, `DBName`, and **\*\*** are replaced with their appropriate values. I've also tried using Windows Credentials, and a variety of different server endpoints, including my NB Name, Loopback IP, Static internal IP, blah blah blah. Firewall is OFF. TCP is enabled on the server.

I get the following exception:

> 
> 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: 0 - No connection could be made because the target machine actively refused it.)
> 
> 
> 

Any suggestions?

Answer: 
```
string locationToSavePdf = Path.Combine(Path.GetTempPath(), "file name for your pdf file.pdf");  // select other location if you want
File.WriteAllBytes(locationToSavePdf,Properties.Resources.nameOfFile);    // write the file from the resources to the location you want
Process.Start(locationToSavePdf);    // run the file

```
Add `using System.Diagnostics;` to your using, and then call:

`Process.Start("path to pdf")`

You won't need to find the PDF Reader exe or anything. Just call the path of the file you want.