title: problem with SQL Server and connecting to C#
body: <p>I'm new to programing. I want my program connect to C# but I'm getting this error:</p>
  
  <blockquote>
    <p><strong>System.Data.SqlClient.SqlException</strong>:<br>
    '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.<br>
    (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'</p>
  </blockquote>
  
  <p>My code:</p>
  
  <pre><code>namespace HesabDarinAnbarDari
  {
     public partial class FrmTanzimat : Form
     {
        public FrmTanzimat()
        {
            InitializeComponent();
        }
  
        SqlConnection con = new SqlConnection("Data source=(local);initial catalog=HesabDariDB;integrated security=true");
        SqlCommand cmd = new SqlCommand();
  
        private void FrmTanzimat_Load(object sender, EventArgs e)
        {
        }
  
        private void btnSave_Click(object sender, EventArgs e)
        {
            cmd.Connection = con;
            cmd.Parameters.Clear();
            cmd.CommandText = "insert into Tanzimat (NameFroshqah, Tel, Mobile, Address. Tozih) values (@a, @b, @c, @d, @e)";
  
            cmd.Parameters.AddWithValue("@a", txtNameFroshgah.Text);
            cmd.Parameters.AddWithValue("@b", txtTel.Text);
            cmd.Parameters.AddWithValue("@c", txtMobile.Text);
            cmd.Parameters.AddWithValue("@d", txtAddress.Text);
            cmd.Parameters.AddWithValue("@e", txtTozih.Text);
  
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("done");
        }
     }
  }
  </code></pre>
  
  <p>SQL code :</p>
  
  <pre><code>CREATE TABLE [dbo].[Tanzimat] 
  (
      [idTanzimat]   INT           IDENTITY (1, 1) NOT NULL,
      [NameFroshgah] NVARCHAR(50)  NULL,
      [Tel]          NVARCHAR(50)  NULL,
      [Mobile]       NVARCHAR(50)  NULL,
      [Address]      NVARCHAR(MAX) NULL,
      [Tozih]        NVARCHAR(MAX) NULL,
  
      CONSTRAINT [PK_Tanzimat] PRIMARY KEY CLUSTERED ([idTanzimat] ASC)
  );
  </code></pre>