title: How to modify the existing SQL connection in excel workbook using c# and then refresh the data
body: <p>I have Excel file which has SQL connection in workbook to fetch the data from SQL Server, I want to update the connection string using c# program but I am unable to get to the connection string value and can not update that. After first step I want to refresh the data for the same connection.
  With the below code I am able to get the connection names but I am not able to find the way to modify it after that I can refresh the data with updated connection.</p>
  
  <pre><code>    private static void RefreshTheExcelData()
      {
          Application application_PMR = new Application();
  
          Workbook workbook_PMR = application_PMR.Workbooks.Open(filePath);
  
          var workBook_Connection = workbook_PMR.Connections;
  
          foreach (WorkbookConnection cn in workbook_PMR.Connections)
              Console.WriteLine(cn.Name);
      }
  </code></pre>