473,660 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connection string is class module

Hello,

I put the connection string to the Web.config file, then in Global.asax I'm
assigning this string to the application variable:

cn = New OracleConnectio n
cn.ConnectionSt ring =
AppCrypto.decry pt(Configuratio nSettings.AppSe ttings("Connect ionString"))

Then I use this to variable to connect to the server:

cn = New OracleConnectio n(Application(" ConnectionStrin g"))

Everything works great with the webforms. However, to keep my connection
code in one place, I put all my connection code in the class module. But in
the class module this doesn't work! I have to use exactly the same code as
in the Global.asax:

cn = New OracleConnectio n
cn.ConnectionSt ring =
AppCrypto.decry pt(Configuratio nSettings.AppSe ttings("Connect ionString"))

This is not acceptable, because the connection is encripted, and if it gets
decripted every time my application connects to the database, it slows
things down badly.

Why the application variable doesn't work in the class module? Probably I'm
doing something incorrectly. The only solution I see now is to drop my
connection class and connect to db in the webforms, which is not a smart
application design.

Is there a better solution? I would appreciate your advice very much.

Thank you,

--
Peter Afonin
May 3 '06 #1
3 1970
> Hello,

I put the connection string to the Web.config file, then in Global.asax I'm
assigning this string to the application variable:

cn = New OracleConnectio n
cn.ConnectionSt ring =
AppCrypto.decry pt(Configuratio nSettings.AppSe ttings("Connect ionString"))

Then I use this to variable to connect to the server:

cn = New OracleConnectio n(Application(" ConnectionStrin g"))

Everything works great with the webforms. However, to keep my connection
code in one place, I put all my connection code in the class module. But in
the class module this doesn't work! I have to use exactly the same code as
in the Global.asax:

cn = New OracleConnectio n
cn.ConnectionSt ring =
AppCrypto.decry pt(Configuratio nSettings.AppSe ttings("Connect ionString"))

This is not acceptable, because the connection is encripted, and if it gets
decripted every time my application connects to the database, it slows
things down badly.

Why the application variable doesn't work in the class module? Probably I'm
doing something incorrectly. The only solution I see now is to drop my
connection class and connect to db in the webforms, which is not a smart
application design.

Is there a better solution? I would appreciate your advice very much.

Thank you,


From a non-web class you can get to Application (and Request, Response,
Session, ..) with System.Web.Http Context.Current .Application

(but this only works if there really *is* an HttpContext, it will not
work from timer-initiated code for instance)

Hans Kesting
May 3 '06 #2
Thank you very much, Hans.

This:

Dim sCn As String =
System.Web.Http Context.Current .Application.It em("ConnectionS tring")
cn = New OracleConnectio n(sCn)

worked great for me.

Peter

Hans Kesting wrote:
Hello,

I put the connection string to the Web.config file, then in Global.asax I'm
assigning this string to the application variable:

cn = New OracleConnectio n
cn.ConnectionSt ring =
AppCrypto.decry pt(Configuratio nSettings.AppSe ttings("Connect ionString"))

Then I use this to variable to connect to the server:

cn = New OracleConnectio n(Application(" ConnectionStrin g"))

Everything works great with the webforms. However, to keep my connection
code in one place, I put all my connection code in the class module. But in
the class module this doesn't work! I have to use exactly the same code as
in the Global.asax:

cn = New OracleConnectio n
cn.ConnectionSt ring =
AppCrypto.decry pt(Configuratio nSettings.AppSe ttings("Connect ionString"))

This is not acceptable, because the connection is encripted, and if it gets
decripted every time my application connects to the database, it slows
things down badly.

Why the application variable doesn't work in the class module? Probably I'm
doing something incorrectly. The only solution I see now is to drop my
connection class and connect to db in the webforms, which is not a smart
application design.

Is there a better solution? I would appreciate your advice very much.

Thank you,


From a non-web class you can get to Application (and Request, Response,
Session, ..) with System.Web.Http Context.Current .Application

(but this only works if there really *is* an HttpContext, it will not
work from timer-initiated code for instance)

Hans Kesting


May 3 '06 #3
I've just found another solution - if I use module rather than non-web
class, everything works fine.

Thanks again,

Peter

May 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5370
by: Bob | last post by:
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem I'm experiencing is that when many users are hitting the site at once, occasionaly I will see errors. The 3 most common ones are: "The SqlCommand is currently busy Open, Fetching. ", "Internal Connection Fatal Error", "object reference not set to...
1
3219
by: Sean Nolan | last post by:
We have implemented unhandled error trapping at the application level and log these errors to our database. One error, however, the does not get trapped is when the connection pool has exceeded the max number of connections. Obviously, we need to find the place(s) in our code where connections are not closed correctly (espcially in loops), but I'm wondering if it's possible to trap this error and to find out which part of our code (i.e....
0
394
by: Bob | last post by:
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem I'm experiencing is that when many users are hitting the site at once, occasionaly I will see errors. The 3 most common ones are: "The SqlCommand is currently busy Open, Fetching. ", "Internal Connection Fatal Error", "object reference not set to...
5
1988
by: Dave Johnson | last post by:
Working on Asp.net with access database backend,a serious Question in the Class design phase, for accessing the database; Which is Better to make a Connection Class that handles all the ADO Connections for all the other Objects, OR Just make a Connection Module to handle the Database Access,
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.