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

Urgent: Need some advice on Connection

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
for me to set my connection string in my applications. I just need to point
to "localhost" as my data source in my conn string.
It works just fine either in my developmetn server and my production server.
I just need to upload all the project files, and everything will run just
fine, just like it is in my developmetn env.
Then, my hosting decided to separated SQL server into a dedicated machine
(with, of course, diff IP).
That's when the problem started. Because, all my appl which point to
'localhost' couldn't recognize it anymore.
As with my ASP appl, I used to create a single .asp page with my connection
string in it. And just 'include' it on top of every .asp page that needs to
access data.
So, i just need to change the 'data source=' to point to the SQL server for
the production server, and use the ussual 'localhost' when use it in my
development env.
Even though it's a little bit tedious, but it can do the trick.

Now, for ASP.NET. I used to create my SQL server connection from "Server
Explorer" window, which VS automatically created a proper
conn.connectionString in my web.config
But, in every .aspx page that accesses data, (I know all of you know this) I
used to drag & drop SqlDataAdapter or SqlCommand directly onto the page,
which VS automatically created a corresponding SqlConnection based on the
connection I created in "Server Explorer". I changed the conn string in my
web.config but still can't recognize the sql server in production env. It's
because in all pages that I have SqlConn, it's still refer to my
'localhost'.

Is there any quick, efficient and effective way, that I can still work on my
development server (using localhost); and when I uploaded the projects to my
production server I can change the Sql server reference to my hosting's Sql
server IP?

Many thanks in advance,
Mike L.

Nov 19 '05 #1
6 1488
just change the web.config value for the connection string

HTH

Ollie Riches

"Mike L." <gl*******************@yahoo.com> wrote in message
news:#Z**************@TK2MSFTNGP15.phx.gbl...
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 for me to set my connection string in my applications. I just need to point to "localhost" as my data source in my conn string.
It works just fine either in my developmetn server and my production server. I just need to upload all the project files, and everything will run just
fine, just like it is in my developmetn env.
Then, my hosting decided to separated SQL server into a dedicated machine
(with, of course, diff IP).
That's when the problem started. Because, all my appl which point to
'localhost' couldn't recognize it anymore.
As with my ASP appl, I used to create a single .asp page with my connection string in it. And just 'include' it on top of every .asp page that needs to access data.
So, i just need to change the 'data source=' to point to the SQL server for the production server, and use the ussual 'localhost' when use it in my
development env.
Even though it's a little bit tedious, but it can do the trick.

Now, for ASP.NET. I used to create my SQL server connection from "Server
Explorer" window, which VS automatically created a proper
conn.connectionString in my web.config
But, in every .aspx page that accesses data, (I know all of you know this) I used to drag & drop SqlDataAdapter or SqlCommand directly onto the page,
which VS automatically created a corresponding SqlConnection based on the
connection I created in "Server Explorer". I changed the conn string in my
web.config but still can't recognize the sql server in production env. It's because in all pages that I have SqlConn, it's still refer to my
'localhost'.

Is there any quick, efficient and effective way, that I can still work on my development server (using localhost); and when I uploaded the projects to my production server I can change the Sql server reference to my hosting's Sql server IP?

Many thanks in advance,
Mike L.

Nov 19 '05 #2
Ollie,

I did so. It still didn't work. Like I said, In every .aspx page that
accesses data, I drag & drop a SqlConnection from toolbox, which got
populated with my current connection settings (which is points to
localhost).
Any other idea?

thks,
andy
"Ollie Riches" <ol**********@hotmail.com> wrote in message
news:e#**************@tk2msftngp13.phx.gbl...
just change the web.config value for the connection string

HTH

Ollie Riches

"Mike L." <gl*******************@yahoo.com> wrote in message
news:#Z**************@TK2MSFTNGP15.phx.gbl...
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
for me to set my connection string in my applications. I just need to

point
to "localhost" as my data source in my conn string.
It works just fine either in my developmetn server and my production

server.
I just need to upload all the project files, and everything will run

just fine, just like it is in my developmetn env.
Then, my hosting decided to separated SQL server into a dedicated machine (with, of course, diff IP).
That's when the problem started. Because, all my appl which point to
'localhost' couldn't recognize it anymore.
As with my ASP appl, I used to create a single .asp page with my

connection
string in it. And just 'include' it on top of every .asp page that needs

to
access data.
So, i just need to change the 'data source=' to point to the SQL server

for
the production server, and use the ussual 'localhost' when use it in my
development env.
Even though it's a little bit tedious, but it can do the trick.

Now, for ASP.NET. I used to create my SQL server connection from "Server
Explorer" window, which VS automatically created a proper
conn.connectionString in my web.config
But, in every .aspx page that accesses data, (I know all of you know this) I
used to drag & drop SqlDataAdapter or SqlCommand directly onto the page,
which VS automatically created a corresponding SqlConnection based on
the connection I created in "Server Explorer". I changed the conn string in my web.config but still can't recognize the sql server in production env.

It's
because in all pages that I have SqlConn, it's still refer to my
'localhost'.

Is there any quick, efficient and effective way, that I can still work

on my
development server (using localhost); and when I uploaded the projects
to my
production server I can change the Sql server reference to my hosting's

Sql
server IP?

Many thanks in advance,
Mike L.


Nov 19 '05 #3
Hi Mike,

Just change the SQL connection string in your page load event. You can
detect the server it is running on and then substitute the production
server's SQL string. Here's the code:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Request.ServerVariables.Item("SERVER_NAME") <> "localhost" Then
SqlConnection1.ConnectionString = System.Configuration. _
ConfigurationSettings.AppSettings("strSQLConn")
End If

and this goes in the Web.config:

<configuration>
<appSettings>
<add key="strSQLConn" value="workstation id=P4320;user id=userIDHere;data
source=P4320;initial catalog=cathere;password=pwdhere"/>
</appSettings>

<system.web>
"Mike L." <gl*******************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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
for me to set my connection string in my applications. I just need to
point
to "localhost" as my data source in my conn string.
It works just fine either in my developmetn server and my production
server.
I just need to upload all the project files, and everything will run just
fine, just like it is in my developmetn env.
Then, my hosting decided to separated SQL server into a dedicated machine
(with, of course, diff IP).
That's when the problem started. Because, all my appl which point to
'localhost' couldn't recognize it anymore.
As with my ASP appl, I used to create a single .asp page with my
connection
string in it. And just 'include' it on top of every .asp page that needs
to
access data.
So, i just need to change the 'data source=' to point to the SQL server
for
the production server, and use the ussual 'localhost' when use it in my
development env.
Even though it's a little bit tedious, but it can do the trick.

Now, for ASP.NET. I used to create my SQL server connection from "Server
Explorer" window, which VS automatically created a proper
conn.connectionString in my web.config
But, in every .aspx page that accesses data, (I know all of you know this)
I
used to drag & drop SqlDataAdapter or SqlCommand directly onto the page,
which VS automatically created a corresponding SqlConnection based on the
connection I created in "Server Explorer". I changed the conn string in my
web.config but still can't recognize the sql server in production env.
It's
because in all pages that I have SqlConn, it's still refer to my
'localhost'.

Is there any quick, efficient and effective way, that I can still work on
my
development server (using localhost); and when I uploaded the projects to
my
production server I can change the Sql server reference to my hosting's
Sql
server IP?

Many thanks in advance,
Mike L.


Nov 19 '05 #4
"Mike L." <gl*******************@yahoo.com> confessed in news:ea4
#Q***********@TK2MSFTNGP15.phx.gbl:
Ollie,

I did so. It still didn't work. Like I said, In every .aspx page that
accesses data, I drag & drop a SqlConnection from toolbox, which got
populated with my current connection settings (which is points to
localhost).
Any other idea?

thks,
andy
"Ollie Riches" <ol**********@hotmail.com> wrote in message
news:e#**************@tk2msftngp13.phx.gbl...
just change the web.config value for the connection string

HTH

Ollie Riches

"Mike L." <gl*******************@yahoo.com> wrote in message
news:#Z**************@TK2MSFTNGP15.phx.gbl...
> 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
> for me to set my connection string in my applications. I just need to point
> to "localhost" as my data source in my conn string.
> It works just fine either in my developmetn server and my production

server.
> I just need to upload all the project files, and everything will run just > fine, just like it is in my developmetn env.
> Then, my hosting decided to separated SQL server into a dedicated machine > (with, of course, diff IP).
> That's when the problem started. Because, all my appl which point to
> 'localhost' couldn't recognize it anymore.
> As with my ASP appl, I used to create a single .asp page with my

connection
> string in it. And just 'include' it on top of every .asp page that
needs to
> access data.
> So, i just need to change the 'data source=' to point to the SQL
server for
> the production server, and use the ussual 'localhost' when use it in
my > development env.
> Even though it's a little bit tedious, but it can do the trick.
>
> Now, for ASP.NET. I used to create my SQL server connection from "Server > Explorer" window, which VS automatically created a proper
> conn.connectionString in my web.config
> But, in every .aspx page that accesses data, (I know all of you know

this)
I
> used to drag & drop SqlDataAdapter or SqlCommand directly onto the page, > which VS automatically created a corresponding SqlConnection based on

the > connection I created in "Server Explorer". I changed the conn string
in my > web.config but still can't recognize the sql server in production env.

It's
> because in all pages that I have SqlConn, it's still refer to my
> 'localhost'.
>
> Is there any quick, efficient and effective way, that I can still work

on
my
> development server (using localhost); and when I uploaded the projects

to
my
> production server I can change the Sql server reference to my

hosting's Sql
> server IP?
>
> Many thanks in advance,
> Mike L.
>
>
>




Andy or Mike

Don't do that.

Dragging from Server is simply a RAD device that is cool at first, but not
always useful for enterprise development.

Setup a connection string value in Web.config, then use that as your
connection string when needed in your classes.

This way, you change it once (in Web.config) when you change servers. Good
practice, time saver.

-- ipgrunt
Nov 19 '05 #5
thanks guys,

i'll give it a try.

regards,
mike

"Mike L." <gl*******************@yahoo.com> wrote in message
news:#Z**************@TK2MSFTNGP15.phx.gbl...
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 for me to set my connection string in my applications. I just need to point to "localhost" as my data source in my conn string.
It works just fine either in my developmetn server and my production server. I just need to upload all the project files, and everything will run just
fine, just like it is in my developmetn env.
Then, my hosting decided to separated SQL server into a dedicated machine
(with, of course, diff IP).
That's when the problem started. Because, all my appl which point to
'localhost' couldn't recognize it anymore.
As with my ASP appl, I used to create a single .asp page with my connection string in it. And just 'include' it on top of every .asp page that needs to access data.
So, i just need to change the 'data source=' to point to the SQL server for the production server, and use the ussual 'localhost' when use it in my
development env.
Even though it's a little bit tedious, but it can do the trick.

Now, for ASP.NET. I used to create my SQL server connection from "Server
Explorer" window, which VS automatically created a proper
conn.connectionString in my web.config
But, in every .aspx page that accesses data, (I know all of you know this) I used to drag & drop SqlDataAdapter or SqlCommand directly onto the page,
which VS automatically created a corresponding SqlConnection based on the
connection I created in "Server Explorer". I changed the conn string in my
web.config but still can't recognize the sql server in production env. It's because in all pages that I have SqlConn, it's still refer to my
'localhost'.

Is there any quick, efficient and effective way, that I can still work on my development server (using localhost); and when I uploaded the projects to my production server I can change the Sql server reference to my hosting's Sql server IP?

Many thanks in advance,
Mike L.

Nov 19 '05 #6
>So, i just need to change the 'data source=' to point to the SQL server
for the production server, and use the ussual 'localhost' when use it
in my development env. Even though it's a little bit tedious, but it
can do the trick.


Quite aside form the issue you are trying to solve, you could save
yourself a bit of hassle if you add an entry to your HOSTS file.

As an example, suppose your local machine is called HOME, and the two
production machines are called WEB and DATA (dumb names I know, I'm just
making them up for clarity). You are currently using localhost in your
connection string when the site is on your own machine, and having to
change it to DATA before you upload.

Add a line to C:\WINDOWS\System32\Drivers\Etc\HOSTS (no extension) to
fool your machine into thinking that your local machine is called DATA.
That way you can keep your connection string using DATA, and it will
work on both your local machine and the production one.

The downside to this is that you won't be able to access the remote data
machine by name, only by IP address as your HOSTS file will direct any
requests for DATA to localhost, but this is 9in my experience) a very
small price to pay for the convenience.

Hope this helps

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #7

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

Similar topics

3
by: Rob | last post by:
I have a form - when you click the submit button, it appends a variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable) It also opens a new page. Now, that some_dynamic_variable is...
7
by: Alan Pretre | last post by:
I have an application installed at a customer site that has been getting a general network error for a couple of years. I was hoping that .NET 2.0 would clear it up, but unfortunately it didn't. ...
0
by: Miguel Dias Moura | last post by:
Hello, I am working on an Asp.Net 2.0 / SQL 2005 web site. I am using profile to save the users info on the database. For example, I have the following structure: Public Structure Name...
2
by: Max Power | last post by:
Hi All I am coding a small app in that swaps specific files between a client and server. All files and locations are set at both sides. I want my app to show a file list, based on the file...
0
by: alok sengar | last post by:
hi, I have already tried this URL's code "http://www.java2s.com/Code/CSharp/Network/SimpleSNMP.htm" but I am getting error when i am creating a UDP type Socket and recieving packet from this...
1
by: alok sengar | last post by:
hi, I have already tried this URL's code "http://www.java2s.com/Code/CSharp/Network/SimpleSNMP.htm" but I am getting error when i am creating a UDP type Socket and recieving packet from this...
1
by: TexCube | last post by:
Hello everyone, I have an urgent question. Can data be pulled from an access database table to create a directory that can be printed out and bound together? I need to have each row of a...
1
by: doniravi | last post by:
hi all...... this is ravi i m new to this forum..... ok coming to the point i m using database sqlserver n trying to conect through jsp i installed sql server drivr 2000 in my system
1
by: ashi1290 | last post by:
I am getting this error..... Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:120)...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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,...
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...

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.