Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Connection string public module not working.

Posted on 2004-09-29
5
Medium Priority
?
172 Views
Last Modified: 2012-05-05
I have 2 .aspx pages that are populating their data connection string using a public constant that's stored in a module and am encountering mysterious behavior.  For some reason, one of the pages doesn't detect the constants in the module.

Page #1 is older and works correctly, but Page #2 was just added and is giving me "[constant] has not been declared" error message.  The codebehinds of the pages are almost identical, but the newer one isn't detecting the constant in the module, no matter how many times I rebuild the project (including deleting the old DLL, just to be on the safe side).

The place where it breaks in each code behind is:
>    Dim sqlConn As New SqlConnection(PROVIDER_NAME)
 

The module in question looks like this:

>      Public Module Common
>        Public Const PROVIDER_NAME = "Initial Catalog=Client1;Data Source=WHATEVER;user id=blah;password=blah"
>        Public Const CATALOG_NAME = "Client1"
>       [...]
>      End Module

Any idea what the problem is?

Also, what's the word on modules in ASP.Net?  Are they buggy?

Thanks.



 
0
Comment
Question by:Leprechaun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
GohdanTheMoblin earned 500 total points
ID: 12186258
Try prefixing the variables with the module name, like Common.PROVIDER_NAME.  If this fixes it, then just put an Imports <yournamespace>.Common at the top of your code file.
0
 

Author Comment

by:Leprechaun
ID: 12186336
Thanks, Gohdan.  

I ended up working around it by putting the connection string value in the Web.Config file instead.  But I'll try your fix.

BTW, is there any reason to avoid modules?  If find this behavior odd, so I'm wondering if I'm better off avoiding them.
0
 
LVL 2

Expert Comment

by:GohdanTheMoblin
ID: 12186348
I'm not sure if ASP has specific issues, but I know that from what I've heard and read, use of Modules is discouraged and Microsoft may remove them from VB.  A class with shared members accomplishes the same thing, and fits into the whole object-oriented design better.
0
 

Author Comment

by:Leprechaun
ID: 12190179
That's what I thought.  I actually inherited the code from a developer who works mostly in VB 6.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question