I am having a strange problem connecting to a SQL Server 2000 database from
an ASP.NET application.

The strange thing is that I can connect fine using ADODB in an old-fashioned
ASP application, but I get the message "SQL Server does not exist or access
denied" when I try to connect using the SqlConnection object in an ASP.NET
C# application running on the same machine.

The database is SQL Server 2000 running on Windows Server 2003, and the
development machine is running Windows XP with VS.NET 2003, .NET Framework
1.1.

The database server is named "mydbserver", and the developer machine is
named "mywebserver".

Here is the connection string from the old ASP application:
Provider=SQLOLEDB;Server=mydbserver;Initial
Catalog=Contacts;Trusted_Connection=Yes

Here is the connection string from the new ASP.NET application:
workstation id=mywebserver;packet size=4096;integrated security=SSPI;data
source=mydbserver;persist security info=False;initial catalog=Contacts;

I should also point out that I have no trouble connecting from the VS.NET
environment itself, under the Data Connections subtree in the Server
Explorer pane. The ASP.NET connection string above was generated
automatically for me when I added a SqlConnection object in the designer, so
you would think it would work.

From this I would guess that there's some configuration that's wrong, but
I've tried a number of things and numerous MSDN and google searches with no
luck. I'm hoping someone here can help.

Thanks,
Greg

Re: problem connecting to SQL Server by Miha

Miha
Sun Nov 23 11:48:12 CST 2003

Hi Greg,

Since ASP.NET application runs under very restricted aspnet windows account
it has no privileges to access network plus the account is local to your
computer.

The solutions would be:
- use Sql server authenticaton
- run your application under different account

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Greg Bahns" <greg@no.unwanted.mail.bahns.com> wrote in message
news:e4NWehesDHA.1740@TK2MSFTNGP12.phx.gbl...
> I am having a strange problem connecting to a SQL Server 2000 database
from
> an ASP.NET application.
>
> The strange thing is that I can connect fine using ADODB in an
old-fashioned
> ASP application, but I get the message "SQL Server does not exist or
access
> denied" when I try to connect using the SqlConnection object in an
ASP.NET
> C# application running on the same machine.
>
> The database is SQL Server 2000 running on Windows Server 2003, and the
> development machine is running Windows XP with VS.NET 2003, .NET Framework
> 1.1.
>
> The database server is named "mydbserver", and the developer machine is
> named "mywebserver".
>
> Here is the connection string from the old ASP application:
> Provider=SQLOLEDB;Server=mydbserver;Initial
> Catalog=Contacts;Trusted_Connection=Yes
>
> Here is the connection string from the new ASP.NET application:
> workstation id=mywebserver;packet size=4096;integrated security=SSPI;data
> source=mydbserver;persist security info=False;initial catalog=Contacts;
>
> I should also point out that I have no trouble connecting from the VS.NET
> environment itself, under the Data Connections subtree in the Server
> Explorer pane. The ASP.NET connection string above was generated
> automatically for me when I added a SqlConnection object in the designer,
so
> you would think it would work.
>
> From this I would guess that there's some configuration that's wrong, but
> I've tried a number of things and numerous MSDN and google searches with
no
> luck. I'm hoping someone here can help.
>
> Thanks,
> Greg
>
>
>



Re: problem connecting to SQL Server by Greg

Greg
Sun Nov 23 14:07:08 CST 2003

Thanks for your reply.

I forgot to mention that I am running both the ASP and the ASP.NET
applications under the same account.

I began to wonder if setting the account under the Directory Security tab in
the IIS console applies to ASP.NET, and it this point I'm not sure.

Now I have specified the account using the identity tag in web.config. I'm
now pretty certain that it's running under the desired account, because when
I change the password, the ASP.NET application returns the appropriate
error.

Unfortunately, when I set it all up and try again, I still get the "SQL
Server does not exist or access denied" error.

One more note: this error is returned after 15 seconds, which is the default
connection timeout. This fact seems consistent with "server not found" as
opposed to "access denied".

Thanks,
Greg


"Miha Markic" <miha at rthand com> wrote in message
news:ey8t4nesDHA.3416@tk2msftngp13.phx.gbl...
> Hi Greg,
>
> Since ASP.NET application runs under very restricted aspnet windows
account
> it has no privileges to access network plus the account is local to your
> computer.
>
> The solutions would be:
> - use Sql server authenticaton
> - run your application under different account
>
> --
> Miha Markic - RightHand .NET consulting & development
> miha at rthand com
>
> "Greg Bahns" <greg@no.unwanted.mail.bahns.com> wrote in message
> news:e4NWehesDHA.1740@TK2MSFTNGP12.phx.gbl...
> > I am having a strange problem connecting to a SQL Server 2000 database
> from
> > an ASP.NET application.
> >
> > The strange thing is that I can connect fine using ADODB in an
> old-fashioned
> > ASP application, but I get the message "SQL Server does not exist or
> access
> > denied" when I try to connect using the SqlConnection object in an
> ASP.NET
> > C# application running on the same machine.
> >
> > The database is SQL Server 2000 running on Windows Server 2003, and the
> > development machine is running Windows XP with VS.NET 2003, .NET
Framework
> > 1.1.
> >
> > The database server is named "mydbserver", and the developer machine is
> > named "mywebserver".
> >
> > Here is the connection string from the old ASP application:
> > Provider=SQLOLEDB;Server=mydbserver;Initial
> > Catalog=Contacts;Trusted_Connection=Yes
> >
> > Here is the connection string from the new ASP.NET application:
> > workstation id=mywebserver;packet size=4096;integrated
security=SSPI;data
> > source=mydbserver;persist security info=False;initial catalog=Contacts;
> >
> > I should also point out that I have no trouble connecting from the
VS.NET
> > environment itself, under the Data Connections subtree in the Server
> > Explorer pane. The ASP.NET connection string above was generated
> > automatically for me when I added a SqlConnection object in the
designer,
> so
> > you would think it would work.
> >
> > From this I would guess that there's some configuration that's wrong,
but
> > I've tried a number of things and numerous MSDN and google searches with
> no
> > luck. I'm hoping someone here can help.
> >
> > Thanks,
> > Greg
> >
> >
> >
>
>



Re: problem connecting to SQL Server by kamran

kamran
Sun Nov 23 22:00:49 CST 2003

Try this
instead of using "mydbserver" use its IP address.

"Greg Bahns" <greg@no.unwanted.mail.bahns.com> wrote in message
news:e4NWehesDHA.1740@TK2MSFTNGP12.phx.gbl...
> I am having a strange problem connecting to a SQL Server 2000 database
from
> an ASP.NET application.
>
> The strange thing is that I can connect fine using ADODB in an
old-fashioned
> ASP application, but I get the message "SQL Server does not exist or
access
> denied" when I try to connect using the SqlConnection object in an
ASP.NET
> C# application running on the same machine.
>
> The database is SQL Server 2000 running on Windows Server 2003, and the
> development machine is running Windows XP with VS.NET 2003, .NET Framework
> 1.1.
>
> The database server is named "mydbserver", and the developer machine is
> named "mywebserver".
>
> Here is the connection string from the old ASP application:
> Provider=SQLOLEDB;Server=mydbserver;Initial
> Catalog=Contacts;Trusted_Connection=Yes
>
> Here is the connection string from the new ASP.NET application:
> workstation id=mywebserver;packet size=4096;integrated security=SSPI;data
> source=mydbserver;persist security info=False;initial catalog=Contacts;
>
> I should also point out that I have no trouble connecting from the VS.NET
> environment itself, under the Data Connections subtree in the Server
> Explorer pane. The ASP.NET connection string above was generated
> automatically for me when I added a SqlConnection object in the designer,
so
> you would think it would work.
>
> From this I would guess that there's some configuration that's wrong, but
> I've tried a number of things and numerous MSDN and google searches with
no
> luck. I'm hoping someone here can help.
>
> Thanks,
> Greg
>
>
>



Re: problem connecting to SQL Server by Miha

Miha
Mon Nov 24 02:16:27 CST 2003

Hi Gred,

Does your account have network privileges?
What happens if you switch to sql server authentiacation?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"Greg Bahns" <greg@no.unwanted.mail.bahns.com> wrote in message
news:e%233Pp1fsDHA.1884@TK2MSFTNGP10.phx.gbl...
> Thanks for your reply.
>
> I forgot to mention that I am running both the ASP and the ASP.NET
> applications under the same account.
>
> I began to wonder if setting the account under the Directory Security tab
in
> the IIS console applies to ASP.NET, and it this point I'm not sure.
>
> Now I have specified the account using the identity tag in web.config.
I'm
> now pretty certain that it's running under the desired account, because
when
> I change the password, the ASP.NET application returns the appropriate
> error.
>
> Unfortunately, when I set it all up and try again, I still get the "SQL
> Server does not exist or access denied" error.
>
> One more note: this error is returned after 15 seconds, which is the
default
> connection timeout. This fact seems consistent with "server not found" as
> opposed to "access denied".
>
> Thanks,
> Greg
>
>
> "Miha Markic" <miha at rthand com> wrote in message
> news:ey8t4nesDHA.3416@tk2msftngp13.phx.gbl...
> > Hi Greg,
> >
> > Since ASP.NET application runs under very restricted aspnet windows
> account
> > it has no privileges to access network plus the account is local to your
> > computer.
> >
> > The solutions would be:
> > - use Sql server authenticaton
> > - run your application under different account
> >
> > --
> > Miha Markic - RightHand .NET consulting & development
> > miha at rthand com
> >
> > "Greg Bahns" <greg@no.unwanted.mail.bahns.com> wrote in message
> > news:e4NWehesDHA.1740@TK2MSFTNGP12.phx.gbl...
> > > I am having a strange problem connecting to a SQL Server 2000 database
> > from
> > > an ASP.NET application.
> > >
> > > The strange thing is that I can connect fine using ADODB in an
> > old-fashioned
> > > ASP application, but I get the message "SQL Server does not exist or
> > access
> > > denied" when I try to connect using the SqlConnection object in an
> > ASP.NET
> > > C# application running on the same machine.
> > >
> > > The database is SQL Server 2000 running on Windows Server 2003, and
the
> > > development machine is running Windows XP with VS.NET 2003, .NET
> Framework
> > > 1.1.
> > >
> > > The database server is named "mydbserver", and the developer machine
is
> > > named "mywebserver".
> > >
> > > Here is the connection string from the old ASP application:
> > > Provider=SQLOLEDB;Server=mydbserver;Initial
> > > Catalog=Contacts;Trusted_Connection=Yes
> > >
> > > Here is the connection string from the new ASP.NET application:
> > > workstation id=mywebserver;packet size=4096;integrated
> security=SSPI;data
> > > source=mydbserver;persist security info=False;initial
catalog=Contacts;
> > >
> > > I should also point out that I have no trouble connecting from the
> VS.NET
> > > environment itself, under the Data Connections subtree in the Server
> > > Explorer pane. The ASP.NET connection string above was generated
> > > automatically for me when I added a SqlConnection object in the
> designer,
> > so
> > > you would think it would work.
> > >
> > > From this I would guess that there's some configuration that's wrong,
> but
> > > I've tried a number of things and numerous MSDN and google searches
with
> > no
> > > luck. I'm hoping someone here can help.
> > >
> > > Thanks,
> > > Greg
> > >
> > >
> > >
> >
> >
>
>



Re: problem connecting to SQL Server by Greg

Greg
Mon Nov 24 17:10:10 CST 2003

Miha,

I did finally get it working, but I'm confused about it.

Previously, I had added "Network Library=DBMSSOCN" to the
connection string. At some point after that, I added the
identity tag in web.config to ensure that it was running
under the desired account. After removing the Network
Library setting, then it started working. I don't
understand this because I thought DBMSSOCN was the
default, so it shouldn't have made a difference, and
either way I think it should have worked that way.

Also, since in the identity element I specified the same
account that was specfied in the IIS Console, this seems
to imply that the IIS setting was having no effect. Does
that sound right?

Any insight would be appreciated, although at this point
I'm just happy that it's working.

Thanks,
Greg

>-----Original Message-----
>Hi Greg,
>
>Does your account have network privileges?
>What happens if you switch to sql server authentiacation?
>
>--
>Miha Markic - RightHand .NET consulting & software
development
>miha at rthand com
>
>"Greg Bahns" <greg@no.unwanted.mail.bahns.com> wrote in
message
>news:e%233Pp1fsDHA.1884@TK2MSFTNGP10.phx.gbl...
>> Thanks for your reply.
>>
>> I forgot to mention that I am running both the ASP and
the ASP.NET
>> applications under the same account.
>>
>> I began to wonder if setting the account under the
Directory Security tab
>in
>> the IIS console applies to ASP.NET, and it this point
I'm not sure.
>>
>> Now I have specified the account using the identity
tag in web.config.
>I'm
>> now pretty certain that it's running under the desired
account, because
>when
>> I change the password, the ASP.NET application returns
the appropriate
>> error.
>>
>> Unfortunately, when I set it all up and try again, I
still get the "SQL
>> Server does not exist or access denied" error.
>>
>> One more note: this error is returned after 15
seconds, which is the
>default
>> connection timeout. This fact seems consistent
with "server not found" as
>> opposed to "access denied".
>>
>> Thanks,
>> Greg
>>
>>
>> "Miha Markic" <miha at rthand com> wrote in message
>> news:ey8t4nesDHA.3416@tk2msftngp13.phx.gbl...
>> > Hi Greg,
>> >
>> > Since ASP.NET application runs under very restricted
aspnet windows
>> account
>> > it has no privileges to access network plus the
account is local to your
>> > computer.
>> >
>> > The solutions would be:
>> > - use Sql server authenticaton
>> > - run your application under different account
>> >
>> > --
>> > Miha Markic - RightHand .NET consulting & development
>> > miha at rthand com
>> >
>> > "Greg Bahns" <greg@no.unwanted.mail.bahns.com> wrote
in message
>> > news:e4NWehesDHA.1740@TK2MSFTNGP12.phx.gbl...
>> > > I am having a strange problem connecting to a SQL
Server 2000 database
>> > from
>> > > an ASP.NET application.
>> > >
>> > > The strange thing is that I can connect fine using
ADODB in an
>> > old-fashioned
>> > > ASP application, but I get the message "SQL Server
does not exist or
>> > access
>> > > denied" when I try to connect using the
SqlConnection object in an
>> > ASP.NET
>> > > C# application running on the same machine.
>> > >
>> > > The database is SQL Server 2000 running on Windows
Server 2003, and
>the
>> > > development machine is running Windows XP with
VS.NET 2003, .NET
>> Framework
>> > > 1.1.
>> > >
>> > > The database server is named "mydbserver", and the
developer machine
>is
>> > > named "mywebserver".
>> > >
>> > > Here is the connection string from the old ASP
application:
>> > > Provider=SQLOLEDB;Server=mydbserver;Initial
>> > > Catalog=Contacts;Trusted_Connection=Yes
>> > >
>> > > Here is the connection string from the new ASP.NET
application:
>> > > workstation id=mywebserver;packet
size=4096;integrated
>> security=SSPI;data
>> > > source=mydbserver;persist security
info=False;initial
>catalog=Contacts;
>> > >
>> > > I should also point out that I have no trouble
connecting from the
>> VS.NET
>> > > environment itself, under the Data Connections
subtree in the Server
>> > > Explorer pane. The ASP.NET connection string
above was generated
>> > > automatically for me when I added a SqlConnection
object in the
>> designer,
>> > so
>> > > you would think it would work.
>> > >
>> > > From this I would guess that there's some
configuration that's wrong,
>> but
>> > > I've tried a number of things and numerous MSDN
and google searches
>with
>> > no
>> > > luck. I'm hoping someone here can help.
>> > >
>> > > Thanks,
>> > > Greg
>> > >
>> > >
>> > >
>> >
>> >
>>
>>
>
>
>.
>

Re: problem connecting to SQL Server by Miha

Miha
Tue Nov 25 02:45:56 CST 2003

Hi,

"Greg Bahns" <anonymous@discussions.microsoft.com> wrote in message
news:583c01c3b2e0$1bb76c90$a601280a@phx.gbl...
> Miha,
>
> I did finally get it working, but I'm confused about it.
>
> Previously, I had added "Network Library=DBMSSOCN" to the
> connection string. At some point after that, I added the
> identity tag in web.config to ensure that it was running
> under the desired account. After removing the Network
> Library setting, then it started working. I don't
> understand this because I thought DBMSSOCN was the
> default, so it shouldn't have made a difference, and
> either way I think it should have worked that way.
>
> Also, since in the identity element I specified the same
> account that was specfied in the IIS Console, this seems
> to imply that the IIS setting was having no effect. Does
> that sound right?

Yup, I think that identity is managed by app (web.config or perhaps
machine.config or impersonation in code).

> Any insight would be appreciated, although at this point
> I'm just happy that it's working.

Dont' touch it then :)
I normally drag & drop a connection in designer or use ConnectString
property (if you choose new from drop down list) to build my connection
string. Then I copy/paste it to wherever I need it.
Probably it wasn't working with DBMSSOCN becuase it seems that it is
necessary only when working with TCP/IP address, example:
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com