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!

Do While Loop 2

Status
Not open for further replies.

craigward

Programmer
Nov 13, 2007
230
GB
Hi,

I need to remove the first line from a do while loop. Below you can see the code and under that the results. The results are good except for the first row. Because i am pulling the data from a txt file i extract the initial SQL query that is embedded. What would be the best way to delete this row before inserting the uniqueid's in to a table.


Code:
    Set TextStream = file.OpenAsTextStream(ForReading, TristateUseDefault)

    ' Read the file line by line
    Do While Not TextStream.AtEndOfStream
        
        Line = TextStream.readline
    
        ' Do something with "Line"
        Line = Line & vbCRLF		

	qry =  "SELECT firstname, idemail FROM wce_contact where uniqueid = '"&Line&"'"
    
	
        Response.write qry&"</br>"
    Loop


    Set TextStream = nothing





Results:
SELECT firstname, idemail FROM wce_contact where uniqueid = 'lookupsql=select * from wce_contact WHERE (COMPANY LIKE '%wiredcontact%') ORDER BY Surname, COMPANY
'SELECT firstname, idemail FROM wce_contact where uniqueid = 'aPV6aaHXSQ_a
'SELECT firstname, idemail FROM wce_contact where uniqueid = 'gUX.ualWB3fc
'SELECT firstname, idemail FROM wce_contact where uniqueid = 'q9q1ubo24u5gfc3h
'SELECT firstname, idemail FROM wce_contact where uniqueid = '000000000001
'SELECT firstname, idemail FROM wce_contact where uniqueid = 'NQjMbh5ipKic
'SELECT firstname, idemail FROM wce_contact where uniqueid = 'K7b9aaAMW)_a
'SELECT firstname, idemail FROM wce_contact where uniqueid = '7wp1r6h3e916l445
'SELECT firstname, idemail FROM wce_contact where uniqueid = 'bBCpiahl3Dfc
'SELECT firstname, idemail FROM wce_contact where uniqueid = 'v4R7carlltYa
'SELECT firstname, idemail FROM wce_contact where uniqueid = 'lpi1uba3dm04w6dh
'
 
read the first line before the loop and throw away the results. Then, keep your existing loop the way it is.

Code:
    Set TextStream = file.OpenAsTextStream(ForReading, TristateUseDefault)

[blue]    ' Read first line, but don't do anything with it.
    Line = TextStream.readline[/blue]

    ' Read the file line by line
    Do While Not TextStream.AtEndOfStream
        
        [blue]' first line overwritten here[/blue]
        Line = TextStream.readline
    
        ' Do something with "Line"
        Line = Line & vbCRLF        

    qry =  "SELECT firstname, idemail FROM wce_contact where uniqueid = '"&Line&"'"
    
    
        Response.write qry&"</br>"
    Loop


    Set TextStream = nothing

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I thought it worked but it ended up that doing that was causing the page to continuely load. As soon as i put it back in the loop it stop that issue. Any other ideas?
 
Look at George's suggestion again... he didnt remove the line from the loop; he left it there, but added it once BEFORE the loop.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top