473,395 Members | 2,713 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,395 software developers and data experts.

problem connecting to my database behind a firewall


hello all,
I have site that I just moved to a new host. It is a dedicated server that
sits behind a dedicated firewall. Most of the site uses classic ASP that are
working fine but I have some parts that I am converting to .NET that can't
seem to access the database.

The server is windows 2k3 and I am using SQL Server 2k.

In my web config file I have the following connection string:

<appSettings>
<add key="emailConn" value="workstation id=SAVAGE;packet size=4096;user
id=xxx;data source=[ip];persist security info=True;initial
catalog=email;password=xxx" />
</appSettings>

Here is the code where I am calling the connection and using it:

Dim txtUser As String = Request.Form("strUserID")
Dim txtPW As String = Trim(Request.Form("strPassword"))
Dim txtPWdb As String
Dim intAdmindb, intDirdb As Integer

Dim cmdPW As New SqlCommand("SELECT strPWD, intAdmin, intDirector
FROM dbo.prtlUser WHERE (strUID)='" & txtUser & "'")

Dim objCon As New SqlConnection(ConfigurationSettings.AppSettings
("emailConn"))

cmdPW.Connection = objCon
cmdPW.Connection.Open()

Dim readPW As SqlDataReader = cmdPW.ExecuteReader()
Do While readPW.Read()
txtPWdb = readPW(0)
intAdmindb = readPW(1)
intDirdb = readPW(2)
Loop
If txtPW = txtPWdb And txtPW <> "" Then
Dim strUIDs As String
Session("strUIDs") = txtUser
Session("intAdmins") = intAdmindb
Session("intDirs") = intDirdb
Response.Redirect("default.aspx")
Else
Panel1.Visible = False
Panel2.Visible = True
End If
objCon.Close()

As you can see this is a log in page where some one enters a log in and pw
and it checks to see if it is a valid match.

In my classic ASP stuff, since I am behind the firewall instead of using the
external ip of the server I use the internal one 192.168.0.2. However, on
the new server, I have tried using the external IP (this worked with the old
server), the internal IP, and even setting the datasource as things like
localhost and (local). Everytime I get the following error:

SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: SQL Server does not
exist or access denied.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

At first I thought it might be a permissions error, but when I set the
connection string in the config file to the external IP, and I run this on my
local machine, it can connect to the database and run with no problem. I am
convinced it has something to do with the firewall, but I have no idea what
to do about it.

Any help would be greatly appreciated.
Nov 19 '05 #1
7 1754
It seems to be a Networking problem. You need check if you want network
connection to the database server.

Mariano

"Greg W via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:51***********@DotNetMonster.com...

hello all,
I have site that I just moved to a new host. It is a dedicated server
that
sits behind a dedicated firewall. Most of the site uses classic ASP that
are
working fine but I have some parts that I am converting to .NET that can't
seem to access the database.

The server is windows 2k3 and I am using SQL Server 2k.

In my web config file I have the following connection string:

<appSettings>
<add key="emailConn" value="workstation id=SAVAGE;packet size=4096;user
id=xxx;data source=[ip];persist security info=True;initial
catalog=email;password=xxx" />
</appSettings>

Here is the code where I am calling the connection and using it:

Dim txtUser As String = Request.Form("strUserID")
Dim txtPW As String = Trim(Request.Form("strPassword"))
Dim txtPWdb As String
Dim intAdmindb, intDirdb As Integer

Dim cmdPW As New SqlCommand("SELECT strPWD, intAdmin,
intDirector
FROM dbo.prtlUser WHERE (strUID)='" & txtUser & "'")

Dim objCon As New
SqlConnection(ConfigurationSettings.AppSettings
("emailConn"))

cmdPW.Connection = objCon
cmdPW.Connection.Open()

Dim readPW As SqlDataReader = cmdPW.ExecuteReader()
Do While readPW.Read()
txtPWdb = readPW(0)
intAdmindb = readPW(1)
intDirdb = readPW(2)
Loop
If txtPW = txtPWdb And txtPW <> "" Then
Dim strUIDs As String
Session("strUIDs") = txtUser
Session("intAdmins") = intAdmindb
Session("intDirs") = intDirdb
Response.Redirect("default.aspx")
Else
Panel1.Visible = False
Panel2.Visible = True
End If
objCon.Close()

As you can see this is a log in page where some one enters a log in and pw
and it checks to see if it is a valid match.

In my classic ASP stuff, since I am behind the firewall instead of using
the
external ip of the server I use the internal one 192.168.0.2. However, on
the new server, I have tried using the external IP (this worked with the
old
server), the internal IP, and even setting the datasource as things like
localhost and (local). Everytime I get the following error:

SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: SQL Server does not
exist or access denied.

Source Error:

An unhandled exception was generated during the execution of the current
web
request. Information regarding the origin and location of the exception
can
be identified using the exception stack trace below.

At first I thought it might be a permissions error, but when I set the
connection string in the config file to the external IP, and I run this on
my
local machine, it can connect to the database and run with no problem. I
am
convinced it has something to do with the firewall, but I have no idea
what
to do about it.

Any help would be greatly appreciated.

Nov 19 '05 #2

Mariano Omar Rodriguez wrote:
*It seems to be a Networking problem. You need check if you want
network
connection to the database server.

Mariano

*


Im sorry, i don't follow. The SQL Server is running on the same
machine as the web server In classic ASP I can connect to the db with
no problem, it is just in .NET I have a problem.

--
a22042
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 19 '05 #3
I would start by just trying to get your application to connect to the
database. Try creating a new page with the following code, update your
ip, uid and password parameters. I have a feeling it's something simple
that you may be overlooking -- the first thing I'd recommend is that
you verify your connection string and your appsetting (I'm winging it
here, hopefully there's no syntax errors):

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat=server>
Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
With New
SqlConnection("server=[ip];database=master;uid=xxx;password=xxx;")
.Open()
.Close()
End With
End Sub
</script>

Nov 19 '05 #4

OK, that worked, but I cant see why it wont work in the app. It worked fine
on the other server. And when I debug from my local machine (and use the
external ip) it works fine as well.

Alan Samet wrote:
I would start by just trying to get your application to connect to the
database. Try creating a new page with the following code, update your
ip, uid and password parameters. I have a feeling it's something simple
that you may be overlooking -- the first thing I'd recommend is that
you verify your connection string and your appsetting (I'm winging it
here, hopefully there's no syntax errors):

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat=server>
Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
With New
SqlConnection("server=[ip];database=master;uid=xxx;password=xxx;")
.Open()
.Close()
End With
End Sub
</script>

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #5
I'm wondering if it's a deployment issue. If you're using codebehinds,
have you deployed the compiled dll to the bin directory of the server?
Also, verify that your web.config is updated.

-Alan

Nov 19 '05 #6

Oh crap, thank you very much, I thought I had coppied over the the bin folder,
but must have forgotten, that is exactly it.

Alan Samet wrote:
I'm wondering if it's a deployment issue. If you're using codebehinds,
have you deployed the compiled dll to the bin directory of the server?
Also, verify that your web.config is updated.

-Alan

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200507/1
Nov 19 '05 #7
I thought that may've been it. I'd say that belongs near or at the top
of the list for common ASP.NET oversights that cause developers a lot
of frustration :)

-Alan

Nov 19 '05 #8

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

Similar topics

3
by: p cooper | last post by:
router root # perl -MCPAN -e 'install Net::SMTP' CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz...
5
by: Matt | last post by:
I know it is possible to establish a connection to an SQL Server over the Internet via Enterprise Manager. My question is, how secure is this connection? Is there a best practices document for this...
2
by: Vaap | last post by:
I did lot of googling to see if I can solve the SQL server not found problem while trying to run ASP.Net community starter kit from an XP machine to Windows 2003 server hosting SQL server 2000...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
0
by: kgoods | last post by:
Hope someone has some ideas on this one because I'm fresh out! :) I have a SQL server on our internal network behind a linux firewall and Proxy server 2.0 (WinNT 4.0). It is the backend for an...
3
by: Big Charles | last post by:
Hi, We have developed an ASP.NET web application and are planning to host it in an external Server, which provides us a good bandwidht. We need to put he web application outside because the...
1
by: kimberly.walker | last post by:
Im new to creating a web service..... I have a public web page that collects data this is stored in an .mdb. The plan is to create a web service behind the firewall to get the data from the .mdb...
8
by: mouac01 | last post by:
I'm not sure if this is possible. I would like to have a PHP app on the Internet connect and write to a local database (Intranet). For example, users would go to a web site...
2
by: orandov | last post by:
Hi, I am having a problem connecting my .net applications from the application server to the database server. When I run the application from my windows xp (sp2) box it works fine. When I try to...
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

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.