Sub ChangeSQL() 
Dim dbConnections As Excel.Connections
Dim dbWorkbookConnection As Excel.WorkbookConnection
Dim dbOLEDBConnection As Excel.OLEDBConnection

Set dbConnections = ActiveWorkbook.Connections
Set dbWorkbookConnection = dbConnections.Item("Northwind")
Set dbOLEDBConnection = dbWorkbookConnection.OLEDBConnection

dbOLEDBConnection.CommandText = "SELECT * FROM Orders"
End Sub

If you change just the order of the select columns the change is not always refrected when you refresh

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext