I have a main project which references several DLLs. Each DLL will
access the same database as the main project. I'm storing the
connection string within the main project's "web.config " file, so in
theory the DLLs do not have "visibility " to the connection string.
I considered creating a public sub within each DLL (class) which allows
the connection string to be set (but not read):
Public Class myClass
'DATA CONNECTION
Private mobjDataConnect ion As New SqlClient.SqlCo nnection
Public Sub SetConnectionSt ring(ByVal strValue As String)
mobjDataConnect ion.ConnectionS tring = strValue
End Sub
...
...
End Class
This way, only the main project's Web.Config file needs to contain the
connection string. The main project will simply pass the string to the
"SetConnectionS tring" method of the class.
Is this secure? If not, any suggestions? 4 3198
Yes, this sounds like a good solution to me.
Another solution would be to have the middle tier (your business logic DLLs)
manage the connection string so the UI layer (your pages) wouldn't have any
visibility to it.
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Jeff" <jr***@usa.ne t> wrote in message
news:11******** **************@ l41g2000cwc.goo glegroups.com.. . I have a main project which references several DLLs. Each DLL will access the same database as the main project. I'm storing the connection string within the main project's "web.config " file, so in theory the DLLs do not have "visibility " to the connection string.
I considered creating a public sub within each DLL (class) which allows the connection string to be set (but not read):
Public Class myClass 'DATA CONNECTION Private mobjDataConnect ion As New SqlClient.SqlCo nnection
Public Sub SetConnectionSt ring(ByVal strValue As String) mobjDataConnect ion.ConnectionS tring = strValue End Sub
... ... End Class
This way, only the main project's Web.Config file needs to contain the connection string. The main project will simply pass the string to the "SetConnectionS tring" method of the class.
Is this secure? If not, any suggestions?
"Another solution would be to have the middle tier (your business logic
DLLs)
manage the connection string so the UI layer (your pages) wouldn't have
any
visibility to it."
Thanks for the reply. Regarding your other recommended approach, how
would these DLLs have their own visibility to the main project's
"web.config " file? IOW, how would they know the connection string?
Would I have to give each project (DLL) its own web.config file?
I should clarify that each "business logic DLL" is being
developed/compiled within its own project which does *not* have a
"web.config " file.
In this case the web.config might not be as easy, but any old XML file could
work just as well. You could make it as simple or complex as you need.
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Jeff" <jr***@usa.ne t> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. . "Another solution would be to have the middle tier (your business logic DLLs) manage the connection string so the UI layer (your pages) wouldn't have any visibility to it."
Thanks for the reply. Regarding your other recommended approach, how would these DLLs have their own visibility to the main project's "web.config " file? IOW, how would they know the connection string? Would I have to give each project (DLL) its own web.config file?
I should clarify that each "business logic DLL" is being developed/compiled within its own project which does *not* have a "web.config " file.
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. In this case the web.config might not be as easy, but any old XML file could work just as well. You could make it as simple or complex as you need.
-- I hope this helps, Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Jeff" <jr***@usa.ne t> wrote in message news:11******** **************@ g14g2000cwa.goo glegroups.com.. . "Another solution would be to have the middle tier (your business logic DLLs) manage the connection string so the UI layer (your pages) wouldn't have any visibility to it."
Thanks for the reply. Regarding your other recommended approach, how would these DLLs have their own visibility to the main project's "web.config " file? IOW, how would they know the connection string? Would I have to give each project (DLL) its own web.config file?
I should clarify that each "business logic DLL" is being developed/compiled within its own project which does *not* have a "web.config " file.
You know, in your dll, you don't need to have SetConnectionSt ring to get the
connection string that is stored in the <appSettings> section of the
web.config file?
All you need is to call
Configuration.C onfigurationSet tings.AppSettin gs.GetConfig("C onnectionString ")
to grab the key/value pair with the key ConnectionStrin g. You can call this
from the DAL directly. This way, if you have a Windows Forms application
that needs to use the same BLL/DAL objects that the Web UI uses, it will
define the ConnectionStrin g in it's app.config file and the DAL won't need
to be changed at all. Just calling the GetConfig will do the trick...
Not sure if you knew that or not :)
Mythran This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: No Spam |
last post by:
Dear Access 2003 Users,
Is there any way to launch Terminal Server from Access and pass along
the user name that is in a text box? I believe mstsc.exe can be
passed an IP address (/v), but can you also pass along a username or
password that sits on a form? Thank you.
Kevin
|
by: Ken Allen |
last post by:
I have a .net client/server application using remoting, and I cannot get the
custom exception class to pass from the server to the client. The custom
exception is derived from ApplicationException and is defined in an assembly
common to the client and server components. The custom class merely defines
three (3) constructors -- the null...
|
by: LP |
last post by:
Hello,
Here's the scenario:
Object A opens a Sql Db connection to execute number of SqlCommands. Then it
needs to pass this connection to a constructor of object B which in turn
executes more commands on the same connection.
I have an understanding that if SqlConnection is passed as "value"
(unboxed), object B will create its own copy of...
|
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and click a button to
determine whether the zip code is unique. If the zip code is not unique,
another form/dialog is displayed (fclsLookup) - lookup...
|
by: Jaime Stuardo |
last post by:
Hi all..
I have created a business logic component that is used from my ASP.NET
webform. It works, but connection string to the database is hard coded, as
in this method :
public DataSet GetCategories()
{
SqlConnection conn = new SqlConnection("Data Source=DEVSERVER;Initial
Catalog=XXXX;User ID=X;Password=Y");
| |
by: shade73 |
last post by:
Hey all. I currently have two seperate namespaces and I'm trying to
pass a connection around to them. I want to use the same connection &
leave it open for 6 methods & then close it. However, all 6 of those
methods use that same connection.
So my solution was to pass the SqlConnection as a parameter in each
method. This works, but it...
|
by: Vik |
last post by:
From a Web page, I need to open another page created in another project and
pass some object (a database connetion) to that page. Looks like the second
project has its own Application and Session states.
Thanks.
|
by: Deecrypt |
last post by:
Hi,
Passing a string parameter to a webservice to get the dataset generated
as the result, seems to give me an error suggesting that no parameter
is being passed. However it works if I explicitly state the value as
the parameter. Code in Csharp being developed in VS2005 for ASP.NET.
Below is my webservice code.
public DataSet...
|
by: Dean Slindee |
last post by:
VS2008, .NetFramework 3.5 SP1:
I have built a LINQ data access layer project. When the LINQ data context
was built over an existing SQL2005 database, the connection string for that
database was correctly, automatically, placed into the Settings for the LINQ
project. It works, but it's a "static" connection string.
I would like to be...
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |