473,387 Members | 1,504 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,387 software developers and data experts.

changed sql server db name

Hi guys,

Ok, i have a situation like this:
I have a hosted asp.net web appl. On the back end, i have sql server db -
say, mydb. In this appl, i created a connection (SQLConnection) that refer
to this db.
It worked fine for almost 1,5 year now.
Now the management want to move this appl to another hosting, which dictates
that all sql server created will be named: owner_dbName. So, in this
particular appl, the new db would be named: myName_myDb.
I have changed the connection string in my web.config to refer to the new db
name, it's not working since i create a SQLconnection in every page i
created. The only way is that i have to change the connection setting in
every page to refer to new db name. Now, that would be very tedious, since i
have around 50 pages of it. Not to mention the possibilities if one day the
management would move to another hosting company with yet another sql server
naming policy.
Is there any simple way to change this?

I'll appreciate any helps.

thks in advance,
andy
Nov 19 '05 #1
3 898
Hi,

I assume from what you're saying that you store the connection string
you use to connect to the db in your web.config file. This is good
(some say bad for security reasons and you should store the connection
string elsewhere, e.g. in the registry. however, i'm sure your hosting
company won't give you access to that!). It's good because then you
store the connection string in one place and if this sort of thing
happens you only have to change one string in one place.

You mention you've got to go through every page and change your
SQLConnection? Doesn't each page use the connection string in your
web.config file?

If not, I would advise you modify your site to always use the
connection string in your web.config - therefore meaning you don't have
to edit 50+ files next time your hosting company decides to rename all
databases.

Regards,

Peter Chadwick (MCP)
pe**@code-explorers.com

Nov 19 '05 #2
Thanks for the reply Pete,

Yes, it's true that i created a connection string in my web.config. But, in
every page that access sql data, i dropped a sqlconnection component and
point it to the connection that i set within server explorer. And I refer to
it for all sqldataadapter, sqlcommand that I created within that page. I
thought that this will reflect the connection string in my web.config. Until
this time, when i need to move it elsewhere.
So, ok, I think that you made a point here to always use the conn string
that i set in web.config. But how to do it? Can you pls give me an example,
as i'm new to it.

Thks & brgds,
andy
"Peter Chadwick (MCP)" <pe**@code-explorers.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
Hi,

I assume from what you're saying that you store the connection string
you use to connect to the db in your web.config file. This is good
(some say bad for security reasons and you should store the connection
string elsewhere, e.g. in the registry. however, i'm sure your hosting
company won't give you access to that!). It's good because then you
store the connection string in one place and if this sort of thing
happens you only have to change one string in one place.

You mention you've got to go through every page and change your
SQLConnection? Doesn't each page use the connection string in your
web.config file?

If not, I would advise you modify your site to always use the
connection string in your web.config - therefore meaning you don't have
to edit 50+ files next time your hosting company decides to rename all
databases.

Regards,

Peter Chadwick (MCP)
pe**@code-explorers.com

Nov 19 '05 #3
Hi,

Here is a quick sample (C#) of a SQLConnection getting the connection
string out of the web.config. If you're connection string is in the
appSettings section of your web.config the following should work:

string connectionString =
ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection connection = new SqlConnection(connectionString);

Hope this helps some,
Regards,

Peter Chadwick (MCP)
pe**@code-explorers.com

Nov 19 '05 #4

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

Similar topics

1
by: xixi | last post by:
i have catalog a remote database on my local db2 server, but now the remote database server with same machine name but the ip address changed, so i remove the old one, and try to catalog again...
9
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx)...
1
by: Jaime Stuardo | last post by:
Hi all.... I am programming in ASP.NET 2.0 and VS.NET 2005 Beta 2. I have a MasterPage that provides basic look & feel for my pages. The main form present in the master page has this...
1
by: kashifsulemani | last post by:
Dear All I have a problem ,as i created the new user its password became changed. I logon SQL Server as >> Server Name: localhost >> Server option : window athentication
3
by: awebguynow | last post by:
in other words, Can I make client side mod's before I submit a form and Post ? I guess its just a matter of cycling through the form elements and setting value to null (or empty string) for...
0
by: Kevin A | last post by:
The problem is that the web application mysteriously shuts down (ending all sessions) due to a supposed 'configuration change'. By using ASP.Net Health Monitoring we can determine that the...
7
by: william | last post by:
My question is: Specific memory block where my pointer pointing to changed strangely, seemingly that no statement changed it. Here are two examples I got: ***********1***************** I was...
11
by: Bocah Sableng | last post by:
Hi, I'm new member of this group. I had added new virtual host at my intranet server. The new virtual host configuration on httpd.conf is similar with the old one. At the new virtual host, the...
2
by: Mike | last post by:
I have a text box were I can enter in a list of users. I then have a button that I verify each user. I'm running into an issue, were if I have 3 users entered in the textbox and user #3 is invalid,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
marktang
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,...
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
Oralloy
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,...

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.