• The error you are getting suggests that you should be checking whether the SELECT statement returns anything before you try to use it (in your msgbox)....

    Been a while since I coded anything using ADO (or vbscript) but I think that there is an EOF method. Try the following:

    dim OConn,fso,f1,txt,recordline

    dim rscategory

    Const ForReading=1

    set OConn = CreateObject("ADODB.Connection")

    conn_string="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=DATAMARTSQL;Application Name=Pruebas"

    OConn.Open= conn_string

    set fso = CreateObject("Scripting.FilesystemObject")

    set f1 = fso.GetFolder( "\\bogccswbavaria\Documentos\Pablo")

    set txt = fso.OpenTextFile("\\bogccswbavaria\Documentos\Pablo\lista.txt",ForReading)

    do until txt.AtEndofStream

    recordline=txt.Readline

    Set rsCategory= OConn.Execute("Select * from archivos_pruebas where nombre_archivo like '%"&recordline&"'")

    IF rsCategory.EOF Then

    MsgBox ("No record found")

    Else

    MsgBox rsCategory.GetString

    End if

    loop

    txt.close

    set fso=Nothing

    OConn.Close

    set OConn=Nothing

    Set rsCategory= Nothing

    Main = DTSTaskExecResult_Success