473,767 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="workstat ion id=SAVAGE;packe t size=4096;user
id=xxx;data source=[ip];persist security info=True;initi al
catalog=email;p assword=xxx" />
</appSettings>

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

Dim txtUser As String = Request.Form("s trUserID")
Dim txtPW As String = Trim(Request.Fo rm("strPassword "))
Dim txtPWdb As String
Dim intAdmindb, intDirdb As Integer

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

Dim objCon As New SqlConnection(C onfigurationSet tings.AppSettin gs
("emailConn" ))

cmdPW.Connectio n = objCon
cmdPW.Connectio n.Open()

Dim readPW As SqlDataReader = cmdPW.ExecuteRe ader()
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("strUID s") = txtUser
Session("intAdm ins") = intAdmindb
Session("intDir s") = intDirdb
Response.Redire ct("default.asp x")
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.Sql Client.SqlExcep tion: 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 1775
It seems to be a Networking problem. You need check if you want network
connection to the database server.

Mariano

"Greg W via DotNetMonster.c om" <fo***@DotNetMo nster.com> wrote in message
news:51******** ***@DotNetMonst er.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="workstat ion id=SAVAGE;packe t size=4096;user
id=xxx;data source=[ip];persist security info=True;initi al
catalog=email;p assword=xxx" />
</appSettings>

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

Dim txtUser As String = Request.Form("s trUserID")
Dim txtPW As String = Trim(Request.Fo rm("strPassword "))
Dim txtPWdb As String
Dim intAdmindb, intDirdb As Integer

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

Dim objCon As New
SqlConnection(C onfigurationSet tings.AppSettin gs
("emailConn" ))

cmdPW.Connectio n = objCon
cmdPW.Connectio n.Open()

Dim readPW As SqlDataReader = cmdPW.ExecuteRe ader()
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("strUID s") = txtUser
Session("intAdm ins") = intAdmindb
Session("intDir s") = intDirdb
Response.Redire ct("default.asp x")
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.Sql Client.SqlExcep tion: 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="Syst em.Data.SqlClie nt" %>
<script runat=server>
Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
With New
SqlConnection(" server=[ip];database=maste r;uid=xxx;passw ord=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="Syst em.Data.SqlClie nt" %>
<script runat=server>
Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
With New
SqlConnection( "server=[ip];database=maste r;uid=xxx;passw ord=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.c om
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
12597
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 Couldn't fetch 01mailrc.txt.gz from ftp.perl.org Trying with "/usr/bin/lynx -source" to get ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
5
3660
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 type of connection? Here is my scenario: We are looking to outsource our web hosting. Currently, we upload client sensitive data to our SQL Server databases within our internal network. If we outsource, the SQL server will be on a different
2
3215
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 database. Tried all possible combinations but it still fails. I have Windows 2003 server having SQL Server 2000 installed with SP2. The installation went Ok on a XP professional machine and I was able to create database and user logins etc on...
12
2791
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 both the iis and sql server in a single machine. Not too long ago, the machine had some hardware problems, and management has decided to purchase new servers, for both asp.net and sql server.
0
1378
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 accounting system and can not be placed facing the internet (even in the DMZ). I have several users connecting to it from their workstations in the same subnet. We have a sister company that has an accounting manager here that belongs to our...
3
3418
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 bandwidtht that we have in our local office won't be enough for the number of users that access to our web app. But for backup issues, the database server will be in our local office.
1
1753
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 also a windows application will be created as well so the users can view the data that was submitted off the public website. My question is if I have the web service behind the firewall and connect by opening a port to retrieve the data once the...
8
3849
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 http://www.internet.com to run the app. The app requires an internet connection and is outside of the user's network. The app would have the option to either store data locally or on the Internet. I would like to give users the option to store data locally because...
2
3045
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 connect via SQL Management Studio to the database server from the application server I get the same error. Here is the error:
0
10009
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
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,...
0
8835
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, 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...
1
7381
isladogs
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...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3929
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
3
2806
bsmnconsultancy
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...

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.