cannot connect to DB from ASP.Net app

C

Christian

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
 
R

Ray Dixon [MVP]

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/netframew...l=/library/en-us/dnnetsec/html/secnetch12.asp
for more in-depth info about data access security.
 

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,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top