Hi:
My ASP.NET app opens and closes database connection in several pages.
Rather than hard coding string into every page, is there a place I can put
it where all pages will be able to access it. In days of fat client
programming, I put in INI file. Looking for similar solution.
Thanks,
Charlie 8 1537
Make use of web.config
"Charlie@CB FC" <ch*****@comcas t.net> wrote in message
news:ep******** *****@TK2MSFTNG P11.phx.gbl... Hi:
My ASP.NET app opens and closes database connection in several pages. Rather than hard coding string into every page, is there a place I can put it where all pages will be able to access it. In days of fat client programming, I put in INI file. Looking for similar solution.
Thanks, Charlie
Hi, Charlie,
Here is a sample: http://samples.gotdotnet.com/quickst...%2fconfig1.src
Greetings
Martin
"Charlie@CB FC" <ch*****@comcas t.net> wrote in message
news:ep******** *****@TK2MSFTNG P11.phx.gbl... Hi:
My ASP.NET app opens and closes database connection in several pages. Rather than hard coding string into every page, is there a place I can put it where all pages will be able to access it. In days of fat client programming, I put in INI file. Looking for similar solution.
Thanks, Charlie
Most people aim for web.config, but I would at least encrypt the string if
you do that. There are free books on ASP.NET security at http://msdn.microsoft.com/architecture. Look at the "Patterns and Practices"
section.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
*************** *************** *************** *************** **********
Think Outside the Box!
*************** *************** *************** *************** **********
"Charlie@CB FC" <ch*****@comcas t.net> wrote in message
news:ep******** *****@TK2MSFTNG P11.phx.gbl... Hi:
My ASP.NET app opens and closes database connection in several pages. Rather than hard coding string into every page, is there a place I can put it where all pages will be able to access it. In days of fat client programming, I put in INI file. Looking for similar solution.
Thanks, Charlie
Most people use the web.config, but it certain cases I've found it more
secure to just store it as a global variable within your app where it is
compiled.
-Max
"Charlie@CB FC" <ch*****@comcas t.net> wrote in message
news:ep******** *****@TK2MSFTNG P11.phx.gbl... Hi:
My ASP.NET app opens and closes database connection in several pages. Rather than hard coding string into every page, is there a place I can put it where all pages will be able to access it. In days of fat client programming, I put in INI file. Looking for similar solution.
Thanks, Charlie
If you "store it as a global variable" it must be defined (read
"hard-coded") somewhere. I believe "where" was the question.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Max" <ma*****@portvi sta.com> wrote in message
news:lh******** **************@ twister.tampaba y.rr.com... Most people use the web.config, but it certain cases I've found it more secure to just store it as a global variable within your app where it is compiled.
-Max
"Charlie@CB FC" <ch*****@comcas t.net> wrote in message news:ep******** *****@TK2MSFTNG P11.phx.gbl... Hi:
My ASP.NET app opens and closes database connection in several pages. Rather than hard coding string into every page, is there a place I can
put it where all pages will be able to access it. In days of fat client programming, I put in INI file. Looking for similar solution.
Thanks, Charlie
public class myvars
public shared strConnection = "blah blah blah happy now?"
end class
imports YourAppName.myv ars
strConnection is now a variable you can use anywhere
Be careful what changes this variable as it is shared, and turn off page
errors so it doesn't bomb out and show your connection string to everyone.
-Max
"Kevin Spencer" <ke***@takempis .com> wrote in message
news:OP******** *****@tk2msftng p13.phx.gbl... If you "store it as a global variable" it must be defined (read "hard-coded") somewhere. I believe "where" was the question.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"Max" <ma*****@portvi sta.com> wrote in message news:lh******** **************@ twister.tampaba y.rr.com... Most people use the web.config, but it certain cases I've found it more secure to just store it as a global variable within your app where it is compiled.
-Max
"Charlie@CB FC" <ch*****@comcas t.net> wrote in message news:ep******** *****@TK2MSFTNG P11.phx.gbl... Hi:
My ASP.NET app opens and closes database connection in several pages. Rather than hard coding string into every page, is there a place I can put it where all pages will be able to access it. In days of fat client programming, I put in INI file. Looking for similar solution.
Thanks, Charlie
public shared strConnection as string = "your conn"
you get the idea
"Max" <ma*****@portvi sta.com> wrote in message
news:%D******** **************@ twister.tampaba y.rr.com... public class myvars public shared strConnection = "blah blah blah happy now?" end class
Hi, Max,
As Kevin stated, with this technique the string is hard-coded, which in
other words means it is *not* configurable.
Greetings
Martin
"Max" <ma*****@portvi sta.com> wrote in message
news:%E******** **************@ twister.tampaba y.rr.com... public shared strConnection as string = "your conn"
you get the idea
"Max" <ma*****@portvi sta.com> wrote in message news:%D******** **************@ twister.tampaba y.rr.com... public class myvars public shared strConnection = "blah blah blah happy now?" end class
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike.miller |
last post by:
You could create a static class for the connection with
static properties for the connection object itself and
all of the associated properties. Just be aware that
only one object can use a connection at one time.
As far as the namespace, it depends on whether you will
want to reuse this class for other apps. The normal
naming convention is
CompanyName.MajorSystem.MajorClassification.Etc.
Although, I find it hard to create a new...
|
by: Ed_P. |
last post by:
Hello,
I have the following scenario: I have a solution with 4 projects
Project1 = MainWindow (Windows EXE)
Project2 = PresentationLayer (DLL)
Project3 = BusinessLayer (DLL)
Project4 = DataLayer (DLL)
I have referenced all of the other projects in the first project so that
I could use the objects I've created in them. However, I am running in
|
by: Chris Dunaway |
last post by:
I have a web service that references a data class library which performs
SQL Server access. Since the web service is also a class library, there is
no App.Config, only Web.config. Is Web.Config the place I should store the
connection string?
If I call System.Configuration.ConfigurationSettings.AppConfig from the
data class library, will it read the settings from the web.config or will
it throw an exception?
Thanks
|
by: Saulot |
last post by:
Hi,
Facing a big problem.
In my Default.aspx page, I open a connection with ma Sql Server DataBase
through my objects framework (A "SetDefaultConnectionString" property which
open my connection... work fine with winforms)
My Default.aspx page is a login one.
When I log in, no problem, I got my
Response.Redirect("DefaultEmployee.aspx") which works well. Then, I click on
another Redirect which leads me to the employee's personnal...
|
by: Fernando Lopes |
last post by:
Hi there.
In your opinion, where is the best place to put the connection string of a
web application?
Web.config, a constant into the code?
I'm not using a component server, so it's not an option, ok?
Tks.
Fernando
| |
by: ad |
last post by:
We usually store the connection string of Web Applicaiton in Web.Config.
Now I want to develop WinForm Application.
Where is the better place to store the conneciton string?
|
by: Andrew |
last post by:
Hello, friends,
I have two questions:
(1) In asp.net, where is the best place to store DB connection string? (We
have .dll to handle all DB queries.)
(2) Any sample source code for client side calendar? (We tried web control
calendar. But, each time we selected a date/changed year or month, it would
go back to web server. It would increase a lot network traffic.)
|
by: csgraham74 |
last post by:
Hi guys,
Basically i have been developing in dotnet for a couple of years but
ive had a few issues in regards to error handling.
For example - I have a class that i call passing in a stored procedure
and connection string as a path. My method returns a dataset. In my SP
i have an output parameter which tells me whether the SP select is
successful or not. If i get a error code passed back then i throw an
exception this then returns...
|
by: Nemisis |
last post by:
Guys,
I would like to write a error handler, or something, that will allow
me to write to a database when an error occurs on my site. I am
trying to implement this in the global.asax file a the moment, but am
having problems when a 404 error occurs, i cant access sessionstate.
Is writing this code in the global.asax file the best way to do this?
I have been searching on the net and hear alot about httphandlers?
Will a httphanlder...
|
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...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |