Hello,
I'm developing a website which has a SQL database working through ADO.NET.
When I'm development site I have my personal IIS server as well as my
personal SQL server.
All my connections strings are pointing to this local SQL server.
When I need to upload the modifications to running website I have to
manually change all SQL connections strings because the running SQL server
is placed on other machine and has a different name.
To minimize this extra job I put my connection string into a key inside
web.config file but, even doing this, on all upload job I need to configure
this file.
Another similar problem is related to design time which uses also a
connection to my local SQL server for some DataSet and DataAdapter objects.
When another developer tries to edit these objects it receives an error
message due the same reason, his local SQL server has another name.
How can I make this easier than that?
Is there any way to solve this?
Kindest regards,
Fernando. 3 2061
Hi Fernando,
To get around the issue of different environments, you can use a whole set
of keys, with a different key in the web.config for every deployment
scenario, including running on the localhost. No edits are required
to the web.config once it is set.
For example, these two keys are for the datasource:
<add key="localhost_ DataSource" value="xxxxx" />
<add key="intranet_c orp_com_DataSou rce" value="yyyy" />
In my .vb code, I read the server name and convert it into the key that I
need automatically:
strSERVER_NAME = Replace(Request .ServerVariable s("SERVER_NAME" ), ".", "_")
strDataBaseServ er = ConfigurationSe ttings.AppSetti ngs(strSERVER_N AME &
"_DataSourc e")
Does this help?
Ken
MVP [ASP.NET]
"Fernando Poinho Malard" <fe******@graph system.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Hello,
I'm developing a website which has a SQL database working through ADO.NET.
When I'm development site I have my personal IIS server as well as my personal SQL server. All my connections strings are pointing to this local SQL server. When I need to upload the modifications to running website I have to manually change all SQL connections strings because the running SQL server is placed on other machine and has a different name.
To minimize this extra job I put my connection string into a key inside web.config file but, even doing this, on all upload job I need to configure this file.
Another similar problem is related to design time which uses also a connection to my local SQL server for some DataSet and DataAdapter objects. When another developer tries to edit these objects it receives an error message due the same reason, his local SQL server has another name.
How can I make this easier than that? Is there any way to solve this?
Kindest regards, Fernando.
For local SQL server you should use (local) as a server name (in round
brackets) not your machine name.
So other developer will use his own local SQL server.
It does not seems to be a big job to edit web.config once you are moving it
to production.
But even if you are moving it everyday (like fixing bugs, ... ) then just do
not copy web.config over the one that exists.
George.
"Fernando Poinho Malard" <fe******@graph system.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Hello,
I'm developing a website which has a SQL database working through ADO.NET.
When I'm development site I have my personal IIS server as well as my personal SQL server. All my connections strings are pointing to this local SQL server. When I need to upload the modifications to running website I have to manually change all SQL connections strings because the running SQL server is placed on other machine and has a different name.
To minimize this extra job I put my connection string into a key inside web.config file but, even doing this, on all upload job I need to
configure this file.
Another similar problem is related to design time which uses also a connection to my local SQL server for some DataSet and DataAdapter
objects. When another developer tries to edit these objects it receives an error message due the same reason, his local SQL server has another name.
How can I make this easier than that? Is there any way to solve this?
Kindest regards, Fernando.
Hi Ken,
This seems to solve the runtime problem but not the design time problem once
the connection string is placed inside the code and, at design time, I can't
change this value...
Another issue is if user has more than one SQL instance running...does
"SERVER_NAM E" represents the first instance when machine has more than one
installed?
Regards,
Fernando.
"Ken Cox [Microsoft MVP]" <BA************ @sympatico.ca> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Hi Fernando,
To get around the issue of different environments, you can use a whole set of keys, with a different key in the web.config for every deployment scenario, including running on the localhost. No edits are required to the web.config once it is set.
For example, these two keys are for the datasource:
<add key="localhost_ DataSource" value="xxxxx" /> <add key="intranet_c orp_com_DataSou rce" value="yyyy" />
In my .vb code, I read the server name and convert it into the key that I need automatically:
strSERVER_NAME = Replace(Request .ServerVariable s("SERVER_NAME" ), ".", "_") strDataBaseServ er = ConfigurationSe ttings.AppSetti ngs(strSERVER_N AME & "_DataSourc e")
Does this help?
Ken MVP [ASP.NET]
"Fernando Poinho Malard" <fe******@graph system.com> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Hello,
I'm developing a website which has a SQL database working through
ADO.NET. When I'm development site I have my personal IIS server as well as my personal SQL server. All my connections strings are pointing to this local SQL server. When I need to upload the modifications to running website I have to manually change all SQL connections strings because the running SQL
server is placed on other machine and has a different name.
To minimize this extra job I put my connection string into a key inside web.config file but, even doing this, on all upload job I need to configure this file.
Another similar problem is related to design time which uses also a connection to my local SQL server for some DataSet and DataAdapter objects. When another developer tries to edit these objects it receives an error message due the same reason, his local SQL server has another name.
How can I make this easier than that? Is there any way to solve this?
Kindest regards, Fernando.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Varun |
last post by:
I have a solution which contains windows,web,mobile presentations. Now i want to share the connection string in the web.config file.
i want to write a method in a common layer where i can retrieve the connection string for all the presentations layers
How can i do that? Any suggestions or urls are suggested?
Thank you
|
by: H |
last post by:
This is a question that has haunted me for quite some time.
if you build a 4 tier database application where the 4th tier is the
database server (MS SQL 2000), where do you build the connection string?
The obvious answer is to hard code it into the middle layer and use a config
file.
The problem is the database application needs to be distributed to
purchasing clients. Therefore, you do not know, at development, what the SQL
|
by: Jon Davis |
last post by:
I like the drag-and-drop accessibility of dragging a table to a Web Forms
designer and seeing a SqlDataAdapter automatically created for me.. being
able to create a DataSet from that is fun and exciting, because now with
this schema based data outline Visual Studio provides me with a typed class
for managing data complete with Intellisense menus exposing my own field
names as C# object properties ... cool ..
Anyway, I have a problem. I...
|
by: Mike L. |
last post by:
Hi,
Pls, beware that I'm new to this :)
I've developed several web appl, either with ASP or ASP.NET. All using SQL
server as the back end.
In my development environment, I have a single server running Win2K, which
serves as Web Server and SQL server as well.
And, since my hosting (production server) using the same config; ie: using a
single server to serve both web server and SQL server; it's always been easy
|
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: WebMatrix |
last post by:
Hello,
I have developed a web application that connects to 2 different database
servers. The connection strings with db username + password are stored in
web.config file.
After a code review, one developer suggested that it's a security flaw;
therefore connection strings should be kept somewhere else or encrypted.
My argument is that web.config file is protected by IIS and Windows security
which is the case. And another argument is that...
|
by: =?Utf-8?B?Vmlua2k=?= |
last post by:
Hello Everyone,
I have a question about storing the connection strings to the database
in a config file or database. My manager wants me to store all the connection
strings in a database, but I think it is easier and faster to store the
connection strings in the config file. I was wondering if anyone has any
opinion on this issue so that I can convince my manager.
Thanks.
|
by: Thorsten Dittmar |
last post by:
Hi,
I don't get it. I'm using a typed dataset with table adapters and all
that stuff. I have the database server running locally on my development
system.
Now: when creating a tableadapter I'm asked for the connection and the
connection string is automatically stored in the settings. So far so good.
However, my typed dataset is declared within a dll that implements other
|
by: Brett |
last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a
different box from the web server) and displays the result in a GridView.
The datasource for the GridView is a SQLDataSource. Just to get it to work,
I hard-coded the username and password of a SQL Server account in the
connectionstring in web.config. Once I confirmed that this worked on the
web server, I wanted to remove the hard-coded password from web.config, so I...
|
by: Johnson |
last post by:
I'm trying to fix a "sub optimal" situation with respect to connection
string management. Your thoughtful responses will be appreciated.
I just started with a new client who has a bunch of legacy ASP.NET
applications that all manage connection strings in Web.config the same way,
like this:
This client has one Web.config file per application, and that one Web.config
file is duplicated across all environments (i.e., dev machines, test,...
|
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: 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,...
|
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: 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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: 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
| |
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...
| |