Retain SQL Login information for Microsoft Query using Excel VBA
Surely it's in the first line? ... PWD=itg
-- Regards Andy Wiggins www.BygSoftware.com Home of "Save and BackUp", "The Excel Auditor" and "Byg Tools for VBA" "Ryan" wrote in message ... I trying to open a Microsoft Query using VBA, but I cannot seem to figure out how to store the SQL Database password when running the Query. Listed below is the current code that I'm using DSN = "DSN=e-work;UID=e-work;PWD=itg" SelServer = "e-work" SelPath = "uscles405\inst1\" SqlId = SqlOpen(DSN) With ActiveSheet.QueryTables.Add(Connection:= _ "FINDER;\\USCLES611\PURCHDATA\DATABASE\HK global po FINAL.dqy", Destination:=Range("A1")) .Name = "HK global po FINAL" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = True .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True DSN = "DSN=e-work;UID=e-work;PWD=itg" SelServer = "e-work" SelPath = "uscles405\inst1\" SqlId = SqlOpen(DSN) .Refresh BackgroundQuery:=False End With |
All times are GMT +1. The time now is 01:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com