I have this code to find all query's in a workbook and replace the database name with the "new" database name. All values are being passed appropriately with acceptable values and the code executes fine (even when I step through line by line to verify each point is being hit). The problem that I have is Sheet2 is not actually being replaced, even though when I step through the code it seems to replace...
oWB = (Excel._Workbook)oXL.Workbooks.Open(path + template + ".xls"); oWS = (Excel._Worksheet(oWB.ActiveSheet); oXL.Sheets[2].Select(); foreach (Excel.QueryTable qt in oWS.QueryTables) { qt.Sql.ToString().ToUpper().Replace(template,newOne).Replace(template.newOne); } oXL.Sheets[1].Select(); foreach (Excel.QueryTable qt in oWS.QueryTables) { qt.Sql.ToString().ToUpper().Replace(template,newOne).Replace(template.newOne); }