Misunderstanding ConnectionStrings?

  • Thread starter Shawn Wildermuth
  • Start date
S

Shawn Wildermuth

I have a web project whose web.config has a ConnectionString setup. I have
a second assembly with my Typed DataSets. The designer has created an App.config
file with a connection string in it for the designer to use. The web project
referecnes the data assembly with the TDS's in it. When I deploy this project,
my Typed DataSets are still using the data in the app.config, and not the
one in the web.config. Any idea on how to tell it to get the ConnectionString
data from web.config and ignore the app.config?

Shawn Wildermuth
C# MVP, Author and Speaker
http://adoguy.com
 
G

Guest

As I undestand, your TDS's are in a dll project? Just a thought - you can try
to remove dllname.config file from the bin folder - I think then ASP.Net will
use web.config...
 
S

Steven Cheng[MSFT]

Thanks for Sergey's inputs.

Hi Shawn,

As Sergey has mentioned, when we create the TableAdapter(dataset) in a
class library project, the connection string setting is retrieved from the
Application Settings collection defined there. And actually the application
settings collection is persisted in app.config file... So when we use the
class library assembly in a end client application (winform or asp.net), we
can override those settings in teh application's config file (app.config or
web.config...). If we don't override, they use those default values defined
in class library...

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: Misunderstanding ConnectionStrings?
| thread-index: AcYVe1HDeeq1cHElRLq4Owmrb9gwfA==
| X-WBNR-Posting-Host: 202.7.176.134
| From: "=?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?="
<[email protected]>
| References: <[email protected]>
| Subject: RE: Misunderstanding ConnectionStrings?
| Date: Mon, 9 Jan 2006 16:18:02 -0800
| Lines: 20
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:369653
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| As I undestand, your TDS's are in a dll project? Just a thought - you can
try
| to remove dllname.config file from the bin folder - I think then ASP.Net
will
| use web.config...
|
| "Shawn Wildermuth" wrote:
|
| > I have a web project whose web.config has a ConnectionString setup. I
have
| > a second assembly with my Typed DataSets. The designer has created an
App.config
| > file with a connection string in it for the designer to use. The web
project
| > referecnes the data assembly with the TDS's in it. When I deploy this
project,
| > my Typed DataSets are still using the data in the app.config, and not
the
| > one in the web.config. Any idea on how to tell it to get the
ConnectionString
| > data from web.config and ignore the app.config?
| >
| > Shawn Wildermuth
| > C# MVP, Author and Speaker
| > http://adoguy.com
| >
| >
| >
|
 
S

Shawn Wildermuth

Hello Sergey,

No app.config in the bin folder...what it was is that they are pre-pending
the project name to the connection string, e.g. MyCOmpany.MyAssembly.Settings.SomeOtherStuff.ConnectionStringName.
NO way I can tell to have the dll not create all that namespace clutter
so I had to create a second conneciton string in my web.config:

<connectionString name="myConnString" ... />
<connectionString name="MyCompany.MyAssembly.Settings.SomeOtherStuff.myConnString"
.... />

To make it work. I don't like this solution so if someone knows how to specify
a realisticly named Connection String in the Table Adapter, I'd appreciate
it.

Shawn Wildermuth
C# MVP, Author and Speaker
http://adoguy.com
 
S

Shawn Wildermuth

Hello Steven Cheng[MSFT],

Please see my reply to Sergey. Is there a way to tell the app to use a shorter
connection string name? We only have one so naming it with the entire setting
container is a waste of space and mindshare.

Shawn Wildermuth
C# MVP, Author and Speaker
http://adoguy.com
 
G

Guest

Shawn,

We used the following code to read from the web.config from inside a dll:

string abc_setting = ConfigurationSettings.AppSettings["abc_setting"];

and it works as long as abc_setting is defined in web.config as follows:

<configuration>
..
<appSettings>
....
<add key="abc_setting" value="abc"/>
</appSettings>
....
</configuration>
 
S

Steven Cheng[MSFT]

Thanks for your response Shawn,

As for the connectionstring name it is generated by the AppSettingBase
class's naming convention so as to avoid name clash when deploying to
target application(since the client app could use many other components
.....). Also, if you do want to change the TableAdatper to use a customized
connection string , you can find the underlying code about the connection
intilization of the TableAdapter in the DataSet.Desiger.cs file which is
genernated by IDE, but we do not recommend this since IDE manage these code
and our customization could be override by IDE when performing some changes
through DESIGN TIME view....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Message-ID: <[email protected]>
| From: Shawn Wildermuth <[email protected]>
| Subject: RE: Misunderstanding ConnectionStrings?
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Content-Type: text/plain; charset=iso-8859-1; format=flowed
| X-Newsreader: JetBrains Omea Reader 671.6
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Date: Mon, 09 Jan 2006 18:39:33 -0800
| NNTP-Posting-Host: c-71-56-111-8.hsd1.ga.comcast.net 71.56.111.8
| Lines: 1
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:369670
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello Steven Cheng[MSFT],
|
| Please see my reply to Sergey. Is there a way to tell the app to use a
shorter
| connection string name? We only have one so naming it with the entire
setting
| container is a waste of space and mindshare.
|
| Shawn Wildermuth
| C# MVP, Author and Speaker
| http://adoguy.com
|
| > Thanks for Sergey's inputs.
| >
| > Hi Shawn,
| >
| > As Sergey has mentioned, when we create the TableAdapter(dataset) in a
| > class library project, the connection string setting is retrieved from
| > the Application Settings collection defined there. And actually the
| > application settings collection is persisted in app.config file... So
| > when we use the class library assembly in a end client application
| > (winform or asp.net), we can override those settings in teh
| > application's config file (app.config or web.config...). If we don't
| > override, they use those default values defined in class library...
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | Thread-Topic: Misunderstanding ConnectionStrings?
| > | thread-index: AcYVe1HDeeq1cHElRLq4Owmrb9gwfA==
| > | X-WBNR-Posting-Host: 202.7.176.134
| > | From: "=?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?="
| > <[email protected]>
| > | References: <[email protected]>
| > | Subject: RE: Misunderstanding ConnectionStrings?
| > | Date: Mon, 9 Jan 2006 16:18:02 -0800
| > | Lines: 20
| > | Message-ID: <[email protected]>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path:
| > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:369653
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | As I undestand, your TDS's are in a dll project? Just a thought -
| > you can
| > try
| > | to remove dllname.config file from the bin folder - I think then
| > ASP.Net
| > will
| > | use web.config...
| > |
| > | "Shawn Wildermuth" wrote:
| > |
| > | > I have a web project whose web.config has a ConnectionString
| > setup. I
| > have
| > | > a second assembly with my Typed DataSets. The designer has
| > created an
| > App.config
| > | > file with a connection string in it for the designer to use. The
| > web
| > project
| > | > referecnes the data assembly with the TDS's in it. When I deploy
| > this
| > project,
| > | > my Typed DataSets are still using the data in the app.config, and
| > not
| > the
| > | > one in the web.config. Any idea on how to tell it to get the
| > ConnectionString
| > | > data from web.config and ignore the app.config?
| > | >
| > | > Shawn Wildermuth
| > | > C# MVP, Author and Speaker
| > | > http://adoguy.com
| > | >
| > | >
| > | >
| > |

|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top