object error / loop / new line problems

Results 1 to 2 of 2

Thread: object error / loop / new line problems

  1. #1
    Join Date
    Dec 1969

    Default object error / loop / new line problems

    The objective is to write a text file from sql queries that writes the grantee,auth table,auth table,auth table...etc (no extra spaces) and starts a new line when getting a new grantee.<BR><BR>What&#039;s happening is getting an object required error 424 on the set fa= although it still loops through. It will write the first grantee and the table record set for that grantee and then loop back and write the next grantee but not the tables... it stops there. Also, the new lines are not happening when writing while using the vbcrlf and/or chr(10). Any help is appreciated...thanks! =)<BR><BR><BR> <BR>on error resume next<BR><BR> Dim fa,ta,userval,ww,tt,usersql,tblsql,tblval,n<BR> n = 1<BR> Set fa=Server.CreateObject("Scripting.FileSystemObject ")<BR> If Err.Number &#060;&#062; 0 Then<BR> Response.Write "&#060;p&#062;3-The following Error has occured:&#060;/p&#062;"<BR> Response.Write "&#060;p&#062;Number: " & Err.Number & "&#060;/p&#062;"<BR> Response.Write "&#060;p&#062;Description: " & Err.Description & "&#060;/p&#062;"<BR> Response.Write "&#060;p&#062;Source: " & Err.Source & "&#060;/p&#062;"<BR> Err.Clear<BR> End IF<BR> Set ta=fa.OpenTextFile(Server.MapPath"hawkbcbsdbusers. txt"),2)<BR> usersql = "Select distinct grantee from systpe.systabauth"<BR> Set ww = oConnSQL.execute(usersql) <BR> Do While Not ww.EOF &#039;while there are still users in the recordset<BR> userval = ww.Fields("grantee").Value &#039;set userval to current userid<BR> If left(userval,2) = "id" then &#039;if a valid userid get list of tables for userid<BR> tblsql = "SELECT tbl from systpe.systabauth where grantee = &#039;"&userval&"&#039;"<BR> Set tt = oConnSQL.execute(tblsql) &#039;execute stmt and set tt to table recordset<BR> If not n = 1 then &#039;if n &#060;&#062; 1 then write a carriage return<BR> ta.Writeline("")<BR> n = n + 1<BR> End if<BR> ta.Write(userval) &#039;write the userid value<BR> Do While Not tt.EOF &#039;loop to write ,tablenames until recordset is at end of file<BR> ta.Write ("," & tt.Fields("tbl").Value)<BR> tt.movenext<BR> Loop<BR> ww.movenext<BR> Else &#039;if not a valid userid, skip the record and check the next userid<BR> ww.movenext<BR> End If<BR> Loop

  2. #2
    Join Date
    Dec 1969

    Default Tch tch...ugly ON ERROR...

    Since you do ON ERROR RESUME NEXT at the top of your code and *NEVER* cancel it (via ON ERROR GOTO 0) there is no way we can tell what errors you might actually be getting. EVERY ERROR YOU MIGHT GET is simply IGNORED by your code, as written.<BR><BR>Get rid of the ON ERROR and then maybe we can have a meaningful discussion.<BR><BR>[The code you show there shouldn&#039;t even *COMPILE*, much less run, as you show it.]<BR><BR>[The code is also ugly in that it uses nested queries. Why not a JOIN to avoid that problem?]<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts