Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching a project...

Status
Not open for further replies.

bmgmzp

Programmer
Aug 18, 2006
84
US
Lets say I have a text file full of names of stored procedures and I'd like to do a 'Find In Files' type search using this text file. How would I do this?

Is there any software out there that would do this?

Searching this way would save me from entering each stored procedure name one at a time in the IDE.

Thanks
 
This is how I loop through a text file, but there are many ways.

Code:
Dim FName as String
Dim strIniPath as String
FName="SP_MyStoredProcedure"

 Set FSO = CreateObject("Scripting.FileSystemObject")
    strIniPath = App.Path & "\StoredProcedures.txt"
    If FSO.fileexists(strIniPath) Then
        Set txtFile1 = FSO.OpenTextFile(strIniPath, 1, False)
        On Error GoTo ExitErr
        
        Do While Not txtFile1.AtEndOfStream
        
            strLine = txtFile1.readline
            [b]If strLine = FName then
                  FName=strLine
                  Exit Do
            End If
            
        Loop[/b]
        
    End If
ExitErr:
    txtFile1.Close

I hope this helps.


Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
Here is the StreamReader version of the same code:

Code:
Dim FName as String
Dim SR As System.IO.StreamReader = New System.IO.StreamReader(Application.StartupPath & "\StoredProcedures.txt")
        Dim Line As String
        Do
            Line = SR.ReadLine()
            If Line Is Nothing Then Exit Do
           [b]If strLine = FName then
                  FName=strLine
                  Exit Do
            End If[/b]

        Loop Until Line Is Nothing
        SR.Close()
'''Add a procedure here to run your stored procedure

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top