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!

Array name error

Status
Not open for further replies.

TheCandyman

Technical User
Sep 9, 2002
761
US
I'm trying to loop through a couple of queries to a DB, but i'm having issues using the GetRows. I have a NameArray with 10 items such as:

Council on Bylaws
Council on Communications

So, i wanted to use those names as the array name, and just replace the spaces with an underscore. But i have something a little off in the "Replace"


Code:
	For x=0 to Ubound(NameArray,2)
		Set rs = Conn.Execute(SQL) 
			If NOT rs.EOF And NOT rs.BOF Then
				response.write NameArray(0,x) &"<br>"
				replace(NameArray(0,x)," ","_") = rs.GetRows()
			End If 
		rs.close	
	Next

error message
Code:
Microsoft VBScript runtime  error '800a000d'

Type mismatch: 'replace'
 
Relace is a function - use something like
Code:
mynewstring=Replace(myoldstring,duffchars,newchars)

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
But then 'mynewstring' will be a value holding the name i want to use, and once i assign a value (= rs.GetRows()) then it will be gone. So i don't see how that will work, unless i'm missing your point

?????
Code:
For x=0 to Ubound(NameArray,2)
        Set rs = Conn.Execute(SQL)
            If NOT rs.EOF And NOT rs.BOF Then
                mynewstring=Replace(NameArray(0,x)," ","_")
                mynewstring = rs.GetRows()
            End If
        rs.close    
    Next
 
Sorry I appear to have missed the point! I have never used a variable as the name for another variable - I didn't even realise it was possible. Could you point me to the relevant help file or MSKB item?

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
[tt] [blue]'dim w 'somewhere above[/blue]
For x=0 to Ubound(NameArray,2)
Set rs = Conn.Execute(SQL)
If NOT rs.EOF And NOT rs.BOF Then
response.write NameArray(0,x) &"<br>"
[blue]w=rs.GetRows()
server.execute replace(NameArray(0,x)," ","_") & "=w"[/blue]
End If
rs.close
Next
[/tt]
 
After trying your suggestions and a few other things i have found, nothing seems to work. So i just tossed all the info into one array and just loop through a few times to filter out the correct info.

the Server.Execute is a remote asp page call, similar to a response.redirect. Only it doesn't make the client browser go to another page. So it didn't work while running a variable. Thanks for the suggestions!
 
I see. It is my bad to put server host on execute. I just do brain code all the time and not test it. This should do.
[tt]
'dim w 'somewhere above
For x=0 to Ubound(NameArray,2)
Set rs = Conn.Execute(SQL)
If NOT rs.EOF And NOT rs.BOF Then
response.write NameArray(0,x) &"<br>"
w=rs.GetRows()
[red]'[/red]server.execute replace(NameArray(0,x)," ","_") & "=w"
[red]execute[/red] replace(NameArray(0,x)," ","_") & "=w"
End If
rs.close
Next
[/tt]
But you have to watch the scope of the variable and testing of the above cannot be done without care.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top