Connections


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"
dbWorkbookConnection.Refresh
End Sub

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




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