Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 25th, 2007, 04:48 AM
Registered User
 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Comparing Filenames with dBase info

Hello guys,

Hope anyone of you can help me. I'm working on an update routine. My client uploads files to a folder on the webserver. This is what I need...

I need to compare the value of field("FileName") with the actual filename in the folder. If it does not exist the fileinfo has to be stored in the database. I'm using a FSO to do this.

Here is my code so far...

    Set FSO = CreateObject("Scripting.FileSystemObject") 'Make File System Object
    'Defines the path to the Aangiften Directory
    sPad = GeefPad(TestFilePath) 'Test path
    response.write(sPad & "<BR>")

    Dim rsAangiften
    sql = "SELECT * FROM tblAangiften"
    set rsAangiften=conn.execute(sql)

    Set objFolder = FSO.GetFolder(sPad) 'Return Folder paths to FSO

        For Each objFile In objFolder.Files 'For each File in MainFolder
            If Not rsAangiften.EOF Then
                'While Not rsAangiften.EOF
                    Dim sFileName
                    sFileName = rsAangiften("Bestandsnaam")
                    sFileName = sFileName & "." & rsAangiften("Extentie")

                    If objFile.Name <> sFileName Then
                        response.write("FileName: " & sFileName & "<BR>" & "FSO.FileName: " & objFile.Name & "<BR>")
'' InsertPdf clientID, objFile.Name, objFile.DateCreated, "Nieuw" 'Put pdf file into dBase using stpAangiften_Insert
'' response.write(objFile.Name & "<BR>")
'' response.write(objFile.DateCreated & "<BR>" & "<BR>")
                        rsAangiften.MoveNext
                    End If
                'Wend
            End If
        Next
' rsAangiften.MoveNext
' Wend
' End If

Sorry for the mess :-p still under construction so no need to keep it tidy.

Many thanks in advance,

Grtz,
Helly

 
Old September 26th, 2007, 05:22 AM
Authorized User
 
Join Date: Dec 2006
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

You are Using Query outside the For Loop. Please try this one-
Dim Rs

For Each objFile In bjFolder.Files
   sql = "SELECT * FROM tblAangiften where FileName ="& objFile
   Set Rs=Con.Execute(sql)
   if Not Rs.EOF then
        Response.write(" something ")
   end if
Next






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to handle corrupt filenames jwhvng Excel VBA 0 November 2nd, 2006 06:28 PM
Filenames/Database Comparison scubasteve Access 7 July 16th, 2006 02:39 AM
Fetching filenames from a folder shazia1 VS.NET 2002/2003 1 January 26th, 2006 06:29 PM
get a collection of filenames/paths from a dir? oowllew C# 0 August 13th, 2004 03:52 PM
SQL Server: Copy Table From dbase to other dbase orez SQL Server 2000 3 July 7th, 2004 03:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.