title: The identifier that starts with … is too long. Maximum length is 128
body: <p>I have a problem. I try to create a database backup of a local database.</p>
  
  <p>When I start the program in VS everything is fine because path to database is less than 128 characters. However, when I publish and install the app, path is more than 128 characters in length and I get that error.</p>
  
  <p>On the Internet I found two solutions:</p>
  
  <ol>
  <li>To use a single quote</li>
  <li>To set: <code>SET QUOTED_IDENTIFIER OFF</code> &amp; <code>SET ANSI_NULLS ON</code></li>
  </ol>
  
  <p>but whichever combination I try, I cannot get it right.</p>
  
  <p>Can anyone tell me how to get it right?</p>
  
  <p>My code:</p>
  
  <pre><code>internal void CreateDbBackup(string DbBackupPath)
  {
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
  
      SqlCommand GetDataFile = new SqlCommand();
      GetDataFile.Connection = con;
      GetDataFile.CommandText = "select physical_name from sys.database_files where type = 0";
  
      con.Open();
      string YourDataFile = (string)GetDataFile.ExecuteScalar();
      con.Close();
  
      SqlCommand cmd = con.CreateCommand();
      cmd.CommandText = string.Format(@"BACKUP DATABASE [" + YourDataFile + "] TO  DISK = N'{0}' WITH  INIT ,  NOUNLOAD ,  NOSKIP ,  STATS = 10,  NOFORMAT", DbBackupPath);
  
      con.Open();
      cmd.ExecuteNonQuery();
      con.Close();
  }
  </code></pre>