I am using C# to push an access query to Excel. My syntax works great, but I would now like to name the connection so when a workbook has multiple connections I know which one I should select to modify which specified query. For example, in Excel 2007 when I click the Data Tab and Click Connections - each query that is imported is just named Connection, Connection1, Connection2, Connection3 etc etc Which piece of my code below names the connection or what should I add so that I am able to name the connection? --- If further code is needed please let me know.
Excel.QueryTable qt = oWS.QueryTables.Add(@"ODBC;DSN=MS Access Database;DBQ=" + database + @";DefaultDir="+ database + @";DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;", oWS.get_Range("A2", "A100"),"SELECT * FROM " + queryName); xlRange.Font.Bold = true; qt.EnableRefresh = true; qt.Name = "Imported_Query"; qt.FieldNames = false; qt.RowNumbers = false; qt.FillAdjacentFormulas = false; qt.PreserveFormatting = true; qt.RefreshOnFileOpen = false; qt.BackgroundQuery = true; qt.RefreshStyle = Excel.XlCellInsertionMode.xlOverwriteCells; qt.SavePassword = true; qt.SaveData = true; qt.AdjustColumnWidth = false; qt.RefreshPeriod = 0; qt.PreserveColumnInfo = true; qt.Refresh(true);