You may have another error, if you have more than one record as a result, then you need to move your record pointer, if you do not want to end with an infinite loop, I also cut your code a little on the other hand, you need to close the connection, if You are not going to use it again.
ConnString="DRIVER={SQL Server};SERVER=aardvark002;UID=***;PWD=***;DATABASE=DEW_Users" Set Connection = CreateObject("ADODB.Connection") Connection.Open ConnString Do Until objFile.AtEndofStream strAppName = objFile.ReadLine SQL = "USE Win7AppData SELECT " & Chr(34) & strCountry & Chr(34) & " FROM AppsByCountry WHERE Application = '" & strAppName & "'" Set Recordset = Connection.Execute(SQL) Do While not Recordset.EOF strApproval = Recordset(strCountry) If StrApproval = "YES" Then strApproval = "Approved" Else strApproval = "Denied" End If objExcel.Cells(intRow, 1).Value = strAppname objExcel.Cells(intRow, 2).Value = strCountry objExcel.Cells(intRow, 3).Value = strApproval intRow = intRow + 1 Recordset.MoveNext End If Loop Connection.Close Set Connection = nothing
peter source share