G
Greg W via 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.
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.