SQL Server Connection problem

J

Justin Ray

I've created an ASP.NET application that runs on my local IIS server. It
needs to connect to a SQL Server database on a different machine. The SQL
server is setup for "mixed mode" authentication.

As you can tell from the connection string in the following code, I am using
SQL Authentication.

Dim sConn As String = "Data Source=DEV01;Initial
Catalog=Northwind;User=sa;Password=fakepw"
Dim cn As New SqlConnection(sConn)
cn.Open()

When this code executes I get the following error:

[SqlException: SQL Server does not exist or access denied.]

The exact same code WORKS if I create a Windows form application. It's only
when I run as an ASP.NET app that I have the problem.

Can you give me some direction on this?

Thanks,

Justin
 
J

Justin Ray

Since I'm not using Windows Authentication, the ASPNET user account
shouldn't be the problem, should it?

Hello,

your asp.net user seems to lack sufficient rights!
Check this article:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnnetsec/html/SecNetHT01.asp

Regards,

Tom
-----Original Message-----
I've created an ASP.NET application that runs on my local IIS server. It
needs to connect to a SQL Server database on a different machine. The SQL
server is setup for "mixed mode" authentication.

As you can tell from the connection string in the following code, I am using
SQL Authentication.

Dim sConn As String = "Data Source=DEV01;Initial
Catalog=Northwind;User=sa;Password=fakepw"
Dim cn As New SqlConnection(sConn)
cn.Open()

When this code executes I get the following error:

[SqlException: SQL Server does not exist or access denied.]

The exact same code WORKS if I create a Windows form application. It's only
when I run as an ASP.NET app that I have the problem.

Can you give me some direction on this?

Thanks,

Justin



.
 
J

Justin Ray

Bruce,

Thanks for the suggestion.

In the SQL Client Network utility, TCP/IP is listed first, followed by Named
Pipes.

I modified my connection string like this, but still had the same problem:
"Network Library=DBMSSOCN;Data Source=172.17.1.101,1433;Initial
Catalog=Northwind;User=sa;Password=fakepw"

Any other thoughts?


bruce barker said:
be sure to use tcp/ip rather than named pipes

-- bruce (sqlwork.com)


Justin Ray said:
I've created an ASP.NET application that runs on my local IIS server. It
needs to connect to a SQL Server database on a different machine. The SQL
server is setup for "mixed mode" authentication.

As you can tell from the connection string in the following code, I am using
SQL Authentication.

Dim sConn As String = "Data Source=DEV01;Initial
Catalog=Northwind;User=sa;Password=fakepw"
Dim cn As New SqlConnection(sConn)
cn.Open()

When this code executes I get the following error:

[SqlException: SQL Server does not exist or access denied.]

The exact same code WORKS if I create a Windows form application. It's only
when I run as an ASP.NET app that I have the problem.

Can you give me some direction on this?

Thanks,

Justin
 
J

Justin Ray

Ok, for the next person that has this problem, this is what I have found...

Although I'm using SQL authentication, my IIS server is still making a
server connection using whatever account it is assigned (in my case, the
IUSR_MACHINE account). I could have either used a domain account here that
had permissions on the SQL Server, or I could create a local IUSR_MACHINE
account on the database server. I chose the latter and it worked fine.

I hope this helps someone...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top