How can I prevent "Name redefined" errors when INC

Results 1 to 2 of 2

Thread: How can I prevent "Name redefined" errors when INC

  1. #1
    Join Date
    Dec 1969

    Default How can I prevent "Name redefined" errors when INC

    Hi<BR><BR>I&#039;m starting to put together a small ASP application. My background is VB/C++ so I&#039;m familiar with Classes.<BR><BR>I have a DB connection class, in a file Connection.Class.asp<BR>I have a PageItem class, in a file PageItem.Class.asp, which INCLUDEs Connection.Class.asp<BR><BR>If I INCLUDE PageItem.Class.asp in another asp page (e.g. Display.asp), everything works fine. However, if Display.asp also INCLUDEs Connection.Class.asp, the page fails with a "Name Redefined" error at the "Class Connection" definition line in Connection.Class.asp, as it has tried to define Connection twice.<BR><BR>You normally get round this in C with #DEFINE and #IFDEF to make sure code is not compiled twice, but I can&#039;t see an equivalent in VBScript. Can anyone help?<BR><BR>Thanks<BR>Phil

  2. #2
    Join Date
    Dec 1969

    Default The only way to do it

    is to make sure your code includes a file only once. The best way is to include them at the top of each page that uses them, rather than having nested includes.

Posting Permissions

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