473,394 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Typed DataSet in DLL points to wrong database!

I have a DLL that implements the Business and Data Layers for a number of
different websites. That DLL uses a Strongly Typed DataSet to interface to
the Data Source which is SQL Server.

There is a connection string in the DLL that is causes me grief. It points
at a particular instance of database. I hae to recompile the DLL for each
WebSite.

How can I re-use that DLL on different websites and have it point to
different instances of the Database without recompiling it?? Perhaps
configurable in Web.Config??

TIA,
George
Jun 27 '08 #1
7 1718
set up a connection string in the web config of each site
<connectionStrings>
<add name="MyConnectionString" connectionString="Data
Source=sqlhost.server.com;Initial Catalog=trepiduscom;Persist Security
Info=True;User ID=MYID;Password=XXXX" providerName="System.Data.SqlClient"/>

</connectionStrings>

then create an appconfig name space:
using System.Configuration;

namespace MyCompany.MyName.Dal
{
/// <summary>
/// The AppConfiguaration class for the web.config file connection
string.
/// </summary>
public static class AppConfiguration
{
#region Public Properties

/// <summary>
/// Returns the connectionstring for the application.
/// </summary>
public static string ConnectionString
{
get
{
return
ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
}
}
}
}
then in your connection
area
using (SqlConnection Con = new
SqlConnectionAppConfiguration.ConnectionString))
{
......
......
......
}
just be sure to includ a using MyCompany.MyName.Dal; at the top
--
Share The Knowledge. I need all the help I can get and so do you!
"MaxGruven" wrote:
I have a DLL that implements the Business and Data Layers for a number of
different websites. That DLL uses a Strongly Typed DataSet to interface to
the Data Source which is SQL Server.

There is a connection string in the DLL that is causes me grief. It points
at a particular instance of database. I hae to recompile the DLL for each
WebSite.

How can I re-use that DLL on different websites and have it point to
different instances of the Database without recompiling it?? Perhaps
configurable in Web.Config??

TIA,
George
Jun 27 '08 #2
There is a paren missing
it should be
using (SqlConnection Con = new
SqlConnection(AppConfiguration.ConnectionString))
{
--
Share The Knowledge. I need all the help I can get and so do you!
"Yankee Imperialist Dog" wrote:
set up a connection string in the web config of each site
<connectionStrings>
<add name="MyConnectionString" connectionString="Data
Source=sqlhost.server.com;Initial Catalog=trepiduscom;Persist Security
Info=True;User ID=MYID;Password=XXXX" providerName="System.Data.SqlClient"/>

</connectionStrings>

then create an appconfig name space:
using System.Configuration;

namespace MyCompany.MyName.Dal
{
/// <summary>
/// The AppConfiguaration class for the web.config file connection
string.
/// </summary>
public static class AppConfiguration
{
#region Public Properties

/// <summary>
/// Returns the connectionstring for the application.
/// </summary>
public static string ConnectionString
{
get
{
return
ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
}
}
}
}
then in your connection
area
using (SqlConnection Con = new
SqlConnectionAppConfiguration.ConnectionString))
{
.....
.....
.....
}
just be sure to includ a using MyCompany.MyName.Dal; at the top
--
Share The Knowledge. I need all the help I can get and so do you!
"MaxGruven" wrote:
I have a DLL that implements the Business and Data Layers for a number of
different websites. That DLL uses a Strongly Typed DataSet to interface to
the Data Source which is SQL Server.

There is a connection string in the DLL that is causes me grief. It points
at a particular instance of database. I hae to recompile the DLL for each
WebSite.

How can I re-use that DLL on different websites and have it point to
different instances of the Database without recompiling it?? Perhaps
configurable in Web.Config??

TIA,
George
Jun 27 '08 #3
Since each web site would have its own web.config, set up the connection
string in the <connectionStrings... element
in the Assembly, you would get the proper connection string with:

ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;

Your assembly would need to have a reference to System.Configuration.

Peter

"MaxGruven" <Ma*******@newsgroup.nospamwrote in message
news:04**********************************@microsof t.com...
>I have a DLL that implements the Business and Data Layers for a number of
different websites. That DLL uses a Strongly Typed DataSet to interface
to
the Data Source which is SQL Server.

There is a connection string in the DLL that is causes me grief. It
points
at a particular instance of database. I hae to recompile the DLL for each
WebSite.

How can I re-use that DLL on different websites and have it point to
different instances of the Database without recompiling it?? Perhaps
configurable in Web.Config??

TIA,
George
Jun 27 '08 #4
Where do I put the reference to connection string in the BL/DL Assembly?

Does it go in Project/Properties/Settings or app.config or in code somewhere?

AND

What Connection String gets used when just working on the BL/DL Assembly
when there is no website (during development)??

TIA,
George

"Peter Bromberg [C# MVP]" wrote:
Since each web site would have its own web.config, set up the connection
string in the <connectionStrings... element
in the Assembly, you would get the proper connection string with:

ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;

Your assembly would need to have a reference to System.Configuration.

Peter

"MaxGruven" <Ma*******@newsgroup.nospamwrote in message
news:04**********************************@microsof t.com...
I have a DLL that implements the Business and Data Layers for a number of
different websites. That DLL uses a Strongly Typed DataSet to interface
to
the Data Source which is SQL Server.

There is a connection string in the DLL that is causes me grief. It
points
at a particular instance of database. I hae to recompile the DLL for each
WebSite.

How can I re-use that DLL on different websites and have it point to
different instances of the Database without recompiling it?? Perhaps
configurable in Web.Config??

TIA,
George
Jun 27 '08 #5
Hi George,

As for the TypedDataSet(in class library project)'s connectionstring
problem, it is a common question I've seen. Actually, you can override the
connectionstring in your consumer application(asp.net or other desktop)'s
app.config file.

For example, in your class library, when you created type dataset, it will
generate the following section in the class library's app.config file:

===============

<connectionStrings>
<add
name="ClassLibrary1.Properties.Settings.MYASPDBCon nectionString"
connectionString="Data Source=localhost;Initial
Catalog=MYASPDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
===============

this is generated by the IDE for your typedataset. You can try adding such
a connectionstring entry in your calling application( the asp.net )'s
app.config file to override the default value(compiled in class library
assembly).

here are some former threads where I've mentioened something else about
such customziation of class library's project properties:

#app.config
http://groups.google.com/group/micro.../browse_thread
/thread/cba21e1cfca4585a/d3b4969cae7a600e

#Question on how to manage SQL Server connection string Options
http://groups.google.com/group/micro...rk.webservices
/browse_thread/thread/e8b06265ba1c2b33/3c2a56cc046e4b1c

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?TWF4R3J1dmVu?= <Ma*******@newsgroup.nospam>
References: <04**********************************@microsoft.co m>
<53**********************************@microsoft.co m>
>Subject: Re: Typed DataSet in DLL points to wrong database!
Date: Thu, 5 Jun 2008 15:41:02 -0700
>
Where do I put the reference to connection string in the BL/DL Assembly?

Does it go in Project/Properties/Settings or app.config or in code
somewhere?
>
AND

What Connection String gets used when just working on the BL/DL Assembly
when there is no website (during development)??

TIA,
George

"Peter Bromberg [C# MVP]" wrote:
>Since each web site would have its own web.config, set up the connection
string in the <connectionStrings... element
in the Assembly, you would get the proper connection string with:

ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;

Your assembly would need to have a reference to System.Configuration.

Peter

"MaxGruven" <Ma*******@newsgroup.nospamwrote in message
news:04**********************************@microso ft.com...
>I have a DLL that implements the Business and Data Layers for a number
of
different websites. That DLL uses a Strongly Typed DataSet to
interface
to
the Data Source which is SQL Server.

There is a connection string in the DLL that is causes me grief. It
points
at a particular instance of database. I hae to recompile the DLL for
each
WebSite.

How can I re-use that DLL on different websites and have it point to
different instances of the Database without recompiling it?? Perhaps
configurable in Web.Config??

TIA,
George
Jun 27 '08 #6
That was it Steven!

Thanks for your help,
George

"Steven Cheng [MSFT]" wrote:
Hi George,

As for the TypedDataSet(in class library project)'s connectionstring
problem, it is a common question I've seen. Actually, you can override the
connectionstring in your consumer application(asp.net or other desktop)'s
app.config file.

For example, in your class library, when you created type dataset, it will
generate the following section in the class library's app.config file:

===============

<connectionStrings>
<add
name="ClassLibrary1.Properties.Settings.MYASPDBCon nectionString"
connectionString="Data Source=localhost;Initial
Catalog=MYASPDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
===============

this is generated by the IDE for your typedataset. You can try adding such
a connectionstring entry in your calling application( the asp.net )'s
app.config file to override the default value(compiled in class library
assembly).

here are some former threads where I've mentioened something else about
such customziation of class library's project properties:

#app.config
http://groups.google.com/group/micro.../browse_thread
/thread/cba21e1cfca4585a/d3b4969cae7a600e

#Question on how to manage SQL Server connection string Options
http://groups.google.com/group/micro...rk.webservices
/browse_thread/thread/e8b06265ba1c2b33/3c2a56cc046e4b1c

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?TWF4R3J1dmVu?= <Ma*******@newsgroup.nospam>
References: <04**********************************@microsoft.co m>
<53**********************************@microsoft.co m>
Subject: Re: Typed DataSet in DLL points to wrong database!
Date: Thu, 5 Jun 2008 15:41:02 -0700

Where do I put the reference to connection string in the BL/DL Assembly?

Does it go in Project/Properties/Settings or app.config or in code
somewhere?

AND

What Connection String gets used when just working on the BL/DL Assembly
when there is no website (during development)??

TIA,
George

"Peter Bromberg [C# MVP]" wrote:
Since each web site would have its own web.config, set up the connection
string in the <connectionStrings... element
in the Assembly, you would get the proper connection string with:

ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;

Your assembly would need to have a reference to System.Configuration.

Peter

"MaxGruven" <Ma*******@newsgroup.nospamwrote in message
news:04**********************************@microsof t.com...
I have a DLL that implements the Business and Data Layers for a number
of
different websites. That DLL uses a Strongly Typed DataSet to
interface
to
the Data Source which is SQL Server.

There is a connection string in the DLL that is causes me grief. It
points
at a particular instance of database. I hae to recompile the DLL for
each
WebSite.

How can I re-use that DLL on different websites and have it point to
different instances of the Database without recompiling it?? Perhaps
configurable in Web.Config??

TIA,
George

Jun 27 '08 #7
You're welcome George,

Have a nice day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?TWF4R3J1dmVu?= <Ma*******@newsgroup.nospam>
References: <04**********************************@microsoft.co m>
<53**********************************@microsoft.co m>
<A0**********************************@microsoft.co m>
<fM**************@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: Typed DataSet in DLL points to wrong database!
Date: Fri, 6 Jun 2008 06:54:01 -0700
>
That was it Steven!

Thanks for your help,
George

"Steven Cheng [MSFT]" wrote:
>Hi George,

As for the TypedDataSet(in class library project)'s connectionstring
problem, it is a common question I've seen. Actually, you can override
the
>connectionstring in your consumer application(asp.net or other
desktop)'s
>app.config file.

For example, in your class library, when you created type dataset, it
will
>generate the following section in the class library's app.config file:

===============

<connectionStrings>
<add
name="ClassLibrary1.Properties.Settings.MYASPDBCo nnectionString"
connectionString="Data Source=localhost;Initial
Catalog=MYASPDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
===============

this is generated by the IDE for your typedataset. You can try adding
such
>a connectionstring entry in your calling application( the asp.net )'s
app.config file to override the default value(compiled in class library
assembly).

here are some former threads where I've mentioened something else about
such customziation of class library's project properties:

#app.config
http://groups.google.com/group/micro.../browse_thread
>/thread/cba21e1cfca4585a/d3b4969cae7a600e

#Question on how to manage SQL Server connection string Options
http://groups.google.com/group/micro...rk.webservices
>/browse_thread/thread/e8b06265ba1c2b33/3c2a56cc046e4b1c

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments
and
>suggestions about how we can improve the support we provide to you.
Please
>feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

================================================= =
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
>ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
>where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
>up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
>most efficient resolution. The offering is not appropriate for
situations
>that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
>handled working with a dedicated Microsoft Support Engineer by
contacting
>Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================= =
This posting is provided "AS IS" with no warranties, and confers no
rights.
>>

--------------------
>From: =?Utf-8?B?TWF4R3J1dmVu?= <Ma*******@newsgroup.nospam>
References: <04**********************************@microsoft.co m>
<53**********************************@microsoft.c om>
>Subject: Re: Typed DataSet in DLL points to wrong database!
Date: Thu, 5 Jun 2008 15:41:02 -0700
>
Where do I put the reference to connection string in the BL/DL Assembly?

Does it go in Project/Properties/Settings or app.config or in code
somewhere?
>
AND

What Connection String gets used when just working on the BL/DL
Assembly
>when there is no website (during development)??

TIA,
George

"Peter Bromberg [C# MVP]" wrote:

Since each web site would have its own web.config, set up the
connection
>string in the <connectionStrings... element
in the Assembly, you would get the proper connection string with:

ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;

Your assembly would need to have a reference to System.Configuration.

Peter

"MaxGruven" <Ma*******@newsgroup.nospamwrote in message
news:04**********************************@microso ft.com...
I have a DLL that implements the Business and Data Layers for a
number
>of
different websites. That DLL uses a Strongly Typed DataSet to
interface
to
the Data Source which is SQL Server.

There is a connection string in the DLL that is causes me grief.
It
points
at a particular instance of database. I hae to recompile the DLL
for
>each
WebSite.

How can I re-use that DLL on different websites and have it point to
different instances of the Database without recompiling it??
Perhaps
configurable in Web.Config??

TIA,
George


Jun 27 '08 #8

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

Similar topics

0
by: Natehop | last post by:
I've been attempting to design an n-tiered framework leveraging .NET's strongly typed Dataset. My Framework will serve as the foundation to several client apps from Windows applications to web...
2
by: Rob Richardson | last post by:
Greetings! I have a database with a table named Holdings. I has VB.Net create a .xsd file for it so that I could use a typed dataset with it. The table has 21 rows. If I use ordinary...
1
by: Optimus | last post by:
Hi everyone, I currently develop an application in vs.net 2005 with vb.net. I was trying to use typed dataset and I've got in trouble for converting untyped dataset into Typed DataSet. I don't...
7
by: Bob | last post by:
Hi, I have a typed unbound dataset that is passed to a datahandling class to be filled. The datahandling class fills it from a sproc using an oledbDataAdapter (SQLAnywhere database) The only...
8
by: Harry Strybos | last post by:
Visual Studio 2005 - SP1 - VB.Net on WinXP SP2 I add a typed dataset to my solution and get the following errors : Error 1 sub 'ReadXmlSerializable' cannot be declared 'Overrides' because it...
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
3
by: Surya | last post by:
Dear All, I have problem on inserting a record to database..Although it looked easy.. i have caught up with following issue .. please go ahead and help me to find solution I Need to insert...
4
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their ...
12
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.