PDA

View Full Version : subroutine problem


ShMiL
04-14-2005, 03:12 PM
I have this subroutines used for opening and closing of DB.

dim conn
Sub dbConn ()
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../db/l**h.mdb") & ";Persist Security Info=False"
End Sub
Sub dbClose ()
conn.close
set conn=nothing
End Sub

this is in funcs.asp.

now, I use top.inc and bot.inc for header and footer for my pages.
I included func.asp in top.inc and it works fine - all the pages who has top.inc included with them are working fine.

the problem is with pages that directly includes funcs.asp

I get this error:

Microsoft VBScript compilation error '800a0411'

Name redefined

/board/web/funcs.asp, line 2

dim conn
----^



what could i do?

Morgoth
04-15-2005, 04:07 AM
Hehe, this is a very silly error, and you'll know when you see it.

The pages that you include func.asp to, have the following line already inside:

dim conn


You can only define a variable once, and this error means you are defining it twice.

If you know what this error means and just need help finding the redefinition you'll have to post more code. ;)

glenngv
04-15-2005, 04:37 AM
Don't include funcs.asp in top.inc. Are you sure that all the pages that needs top.inc always need funcs.asp? I bet not. But if they do, let them include top.inc and funcs.asp separately.

Morgoth
04-15-2005, 04:40 AM
...let them include top.inc and funcs.asp separately.

glenngv, I agree with you 100%

ShMiL
04-15-2005, 09:22 AM
The problem is solved but I'll take your advice.
Thanks.