The reason your connection is working from your WinForms app is because it
is using integrated security and using your currently logged in user account
(the account running the WinForms app) to log into the DB. The ASP.NET app
has Anonymous access enabled, so it is attempting to access the database
using the default ASP.NET anonymous user account, which in your case is
PC-WIN2000ASPNET.
You will need to do one of the following:
1) Specify your connection to use SQL security and pass a valid SQL login
username and password in your connection string (or when you open the
connection).
2) Give the PC-WIN2000ASPNET user account access to the database
3) Set your ASP.NET app to require a login and (if the SQL server is on the
same machine as the ASP.NET app). This is not really a great option unless
you're on an internal network, like an intranet.
Check
http://msdn.microsoft.com/netframewo...secnetch12.asp
for more in-depth info about data access security.
--
Ray Dixon - Microsoft MVP
ra*@NOSPAM.greeble.com
(remove NOSPAM. from my e-mail address for a direct reply)
"Christian" <ch***************@pandora.be> wrote in message
news:pO******************@afrodite.telenet-ops.be...
Hi,
from a WinForms-app do I connect to a DB using a connectionstring :
m_sqlConnection.ConnectionString =
" workstation id=\"PC-WIN2000\";
packet size=4096;integrated
security=SSPI; data source=\"PC-WIN2000\\SQLSERVERDB\";
persist security info=False;
initial catalog=Lotto";
That works.
Now, using the same ConnectionString do I try to connect to the same DB
from within a ASP.Net app, but I get an error :
Login failed for user 'PC-WIN2000ASPNET'
First: why doesn't it work ?
and second : where does he get that username ('PC-WIN2000ASPNET' ) from
???
I added User ID = sa; Password=; to the connectionstring but I get exactly
the same error !!!
I downloaded the latest version of MDAC 2.7 servicepack 1 : no improvement
Any ideas ?
chris