cannot connect to DB from ASP.Net app

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default cannot connect to DB from ASP.Net app

    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


    Christian Guest

  2. Similar Questions and Discussions

    1. Can't Connect to FTP, Need Help
      For the past 2 years I have connected to our ftp site through Microsoft Frontpage. I just bought Macromedia Dreamweaver/Contribute as an upgrade,...
    2. i want to use connect old again.
      i am doing chat application,when network failed it can not connect to FMS2, so i can not chat, but when network have got a gain, why I can not chat?...
    3. FCS connect
      Hi Guys, I have a little issue with my connection. i am running my CCTV through my FlashComm Server and I have to start my broadcast manually....
    4. Help Cant Connect?
      I just simply want to connect to my webpage. I already have a website but then it asks me my network path? I dont even know what that is...I have...
    5. How to use “RDS.Connect” to connect to a MS Access database?
      The example I am working from uses the following code which does not work: RDS.Connect = "Provider='sqloledb';Integrated Security='SSPI';Initial ...
  3. #2

    Default Re: cannot connect to DB from ASP.Net app

    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
    [url]http://msdn.microsoft.com/netframework/downloads/samples/default.aspx?pull=/library/en-us/dnnetsec/html/secnetch12.asp[/url]
    for more in-depth info about data access security.


    --
    Ray Dixon - Microsoft MVP
    [email]ray@NOSPAM.greeble.com[/email]
    (remove NOSPAM. from my e-mail address for a direct reply)




    "Christian" <christian.cambier@pandora.be> wrote in message
    news:pOUSa.24701$F92.2621@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
    >
    >

    Ray Dixon [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139