Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBScript returns an error of "Name redefined"

Tags:

vbscript

I have an alert box, and if I'm currently on the test Database, I want the alert box to have different text when compared to live database.

So I declared a variable called isTestDb and set it to True, but I keep getting this annoying error:

Microsoft VBScript compilation error '800a0411'

Name redefined

myfiles/conn_open.asp, line 12

Dim isTestDb
----^

Here is my simple code which sits inside an include at a much higher level than where I'm doing my conditional check, I'm assuming that isn't a problem.

Dim isTestDb

isTestDb = True


-- Much Later in another file somehwere

If isTestDb Then
    Response.Write("<h1>It is set to True</h1>")
    Response.End
Else
    Response.Write("<h1>It is set to False</h1>")
    Response.End
End If

I have checked all my working directory and I'm certain that variable is not set somewhere else by the same name, I even tried different names for the variable and got the exact same error.

like image 605
J86 Avatar asked Nov 13 '13 11:11

J86


2 Answers

In my case this was due to the fact that I had referenced the same file twice in my .asp file using:

<!--#include file="myFile.asp">

And the referenced file had the declaration in it hence the second declaration conflicted with the first

like image 140
rdans Avatar answered Nov 15 '22 11:11

rdans


This is happenning because the variable, isTestDb has already been defined in another page.

like image 36
Fox Avatar answered Nov 15 '22 12:11

Fox