title: Cannot create the SqlConnection Object in C#?
body: <p>I'm writing a simple program to access one local database, yet it says: the type or namespace name sqlconnect could not be found</p>
  
  <p>error message:</p>
  
  <p>An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll</p>
  
  <p>Additional information: 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)</p>
  
  <p>anyone have an idea about that? Thanks</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Data.SqlClient;
  
  namespace SQL_Server_Connect_Test
  {
      class Program
      {
          static void Main(string[] args)
          {
              //using (SqlConnection connection = new SqlConnection("integrated security=SSPI;data source=Bo_Test_Database; persist security info=False; initial catalog=T_User"))
              {
                  SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=Bob_Test_Database; User ID=sa; Password=t123456");
                  con.Open();
                  using (SqlCommand cmd = con.CreateCommand())
                  {
                      cmd.CommandText = "";
                      cmd.ExecuteNonQuery();
                  }
                  con.Close();
                  con.Dispose();
  
              }
              Console.WriteLine("hehe");
          }
  
      }
  }
  </code></pre>
  
  <ul>
  <li><p>I enabled the sa account and the password is valid</p></li>
  <li><p>the database is on local</p></li>
  <li><p>db name = Bob_Test_Database, the table's name is dbo.T_User</p></li>
  </ul>