SQLDataConnection

Discussion in 'MCSD' started by =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=, Jun 2, 2004.

  1. hello
    I have been trying to test a code to connect to an sqlserver database
    all i have done is used a datagrid to display some data from pubs databse in sqlserver
    i have used sqlconnection, sqldataadapter. i have writted code under page load a
    sqldataadapter1.fill(dataset1
    datagrid1.databind()
    when i build and browse the page, I get the message
    Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
    Can you guys explain what is happening? It is really frustrating
    Thanks Papri
    =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=, Jun 2, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=

    Alex Guest

    Hi. Try and check the user and password or the type of authentication on
    your connection string.

    Alejandro.


    "Papri Chakravorty" <> wrote in message
    news:D...
    > hello,
    > I have been trying to test a code to connect to an sqlserver database.
    > all i have done is used a datagrid to display some data from pubs databse

    in sqlserver.
    > i have used sqlconnection, sqldataadapter. i have writted code under page

    load as
    > sqldataadapter1.fill(dataset1)
    > datagrid1.databind().
    > when i build and browse the page, I get the message,
    > Login failed for user '(null)'. Reason: Not associated with a trusted SQL

    Server connection.
    > Can you guys explain what is happening? It is really frustrating.
    > Thanks Papri
    Alex, Jun 2, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=

    Jay Walters Guest

    This is about db permissions.

    If you're using a username and password:

    Enterprise Mgr, right click on local SQL Server instance
    [or what ever instance you're using], I think it's the
    security tab - make sure that you have mixed mode turned
    on (Windows auth and SQL password)

    If you're using an windows auth: then make sure that your
    local ASPNET user has permissions to the database.


    >-----Original Message-----
    >hello,
    >I have been trying to test a code to connect to an

    sqlserver database.
    >all i have done is used a datagrid to display some data

    from pubs databse in sqlserver.
    >i have used sqlconnection, sqldataadapter. i have

    writted code under page load as
    >sqldataadapter1.fill(dataset1)
    >datagrid1.databind().
    >when i build and browse the page, I get the message,
    >Login failed for user '(null)'. Reason: Not associated

    with a trusted SQL Server connection.
    >Can you guys explain what is happening? It is really

    frustrating.
    >Thanks Papri
    >.
    >
    Jay Walters, Jun 2, 2004
    #3
  4. =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=

    Jay Walters Guest

    Looking at your error - [as Alex mentioned] your
    connection string doesn't have a user specified.

    >>Login failed for user '(null)'






    >-----Original Message-----
    >This is about db permissions.
    >
    >If you're using a username and password:
    >
    >Enterprise Mgr, right click on local SQL Server instance
    >[or what ever instance you're using], I think it's the
    >security tab - make sure that you have mixed mode turned
    >on (Windows auth and SQL password)
    >
    >If you're using an windows auth: then make sure that

    your
    >local ASPNET user has permissions to the database.
    >
    >
    >>-----Original Message-----
    >>hello,
    >>I have been trying to test a code to connect to an

    >sqlserver database.
    >>all i have done is used a datagrid to display some data

    >from pubs databse in sqlserver.
    >>i have used sqlconnection, sqldataadapter. i have

    >writted code under page load as
    >>sqldataadapter1.fill(dataset1)
    >>datagrid1.databind().
    >>when i build and browse the page, I get the message,
    >>Login failed for user '(null)'. Reason: Not associated

    >with a trusted SQL Server connection.
    >>Can you guys explain what is happening? It is really

    >frustrating.
    >>Thanks Papri
    >>.
    >>

    >.
    >
    Jay Walters, Jun 2, 2004
    #4
  5. First uncheck anonymous access in directory security tab of IIS, then in
    web.config put element <impersonate="true"> that will allow to connect to
    SQL server under your account.

    Regards,
    Daniel
    "Papri Chakravorty" <> wrote in message
    news:D...
    > hello,
    > I have been trying to test a code to connect to an sqlserver database.
    > all i have done is used a datagrid to display some data from pubs databse

    in sqlserver.
    > i have used sqlconnection, sqldataadapter. i have writted code under page

    load as
    > sqldataadapter1.fill(dataset1)
    > datagrid1.databind().
    > when i build and browse the page, I get the message,
    > Login failed for user '(null)'. Reason: Not associated with a trusted SQL

    Server connection.
    > Can you guys explain what is happening? It is really frustrating.
    > Thanks Papri
    Daniel Joskovski, Jun 3, 2004
    #5
  6. >First uncheck anonymous access in directory security tab of IIS, then in
    >web.config put element <impersonate="true"> that will allow to connect to
    >SQL server under your account.


    More importantly, the person who posted the original question, should
    gain an understand the consequences of such actions,

    Kline Sphere (Chalk) MCNGP #3
    The Poster Formerly Known as Kline Sphere, Jun 3, 2004
    #6
  7. Agreed, thanks for suggestion.
    This is common situation when first try to do something under ASP.NET, if
    anonymous user access is allowed that mean the user is not authenticated,
    attempt to obtain trusted connection will fail, but only disallowing
    anonymous access is not solution, because after that IIS will authenticate
    ASPNET user account which not have any permission in sql database and it's
    smart to live that way. To solve problem you need to impersonate ASPNET
    account to be Your user account ( which account can have trusted connection
    with SQL server), that can be done in web.config specifying
    <identity impersonate="true" />

    Regards,
    Daniel

    "The Poster Formerly Known as Kline Sphere" <.> wrote in message
    news:...
    > >First uncheck anonymous access in directory security tab of IIS, then in
    > >web.config put element <impersonate="true"> that will allow to connect to
    > >SQL server under your account.

    >
    > More importantly, the person who posted the original question, should
    > gain an understand the consequences of such actions,
    >
    > Kline Sphere (Chalk) MCNGP #3
    Daniel Joskovski, Jun 4, 2004
    #7
  8. =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=

    Jay Walters Guest

    I don't think that's what he was trying to do :)

    I think he's a total newbie and just doesn't have a
    proper connection string...

    The error is : >> Login failed for user '(null)'.

    If he was having trouble connecting with the ASPNET
    account - it would say failed for <LOCAL>\ASPNET



    >-----Original Message-----
    >First uncheck anonymous access in directory security tab

    of IIS, then in
    >web.config put element <impersonate="true"> that will

    allow to connect to
    >SQL server under your account.
    >
    >Regards,
    >Daniel
    >"Papri Chakravorty"

    <> wrote in message
    >news:D477AE02-7FE5-4751-B172-

    ...
    >> hello,
    >> I have been trying to test a code to connect to an

    sqlserver database.
    >> all i have done is used a datagrid to display some

    data from pubs databse
    >in sqlserver.
    >> i have used sqlconnection, sqldataadapter. i have

    writted code under page
    >load as
    >> sqldataadapter1.fill(dataset1)
    >> datagrid1.databind().
    >> when i build and browse the page, I get the message,
    >> Login failed for user '(null)'. Reason: Not associated

    with a trusted SQL
    >Server connection.
    >> Can you guys explain what is happening? It is really

    frustrating.
    >> Thanks Papri

    >
    >
    >.
    >
    Jay Walters, Jun 4, 2004
    #8
  9. Which relates to two other threads posted here recently and highlights
    why security in software development on ms platforms, is simply not
    taken seriously. My point is quite simple, security and software
    development goes hand in hand, always has (to a lesser extent may be)
    and always will.

    The first one: -

    <quote poster='Moe'
    Message-ID='14c5f01c44597$bb8b3fe0$'
    Subject='Re: Training and Career'>

    Very true. But I still question the value in taking the
    time to get certified in those areas if the ultimate
    objective is getting work in development.

    Let's face it. There's sort of an "overhead" involved in
    taking and passing the tests that's somewhat incidental
    to any real learning process. You have to try to get hip
    to what the exam is going to focus on - probably run
    through some practice tests, etc. (I know you don't
    approve, Kline - spare us - OK?). That's all time that
    could be spent learning something important.

    </quote>

    ... second one: -

    <quote =poster='The Poster Formerly Known as Kline Sphere'
    Message-ID=''
    Subject='Re: No news from 70-330/340??'>

    As I've said before, I can't understand why these exams were not never
    part of the dot net certification track. That will change, but why so
    long?

    The way security is ignored in software development on the ms platform
    has always been mad.

    To me, one of few reason to move to dot net, is the excellent
    improvement to code based security over the traditional, non dot net
    development tools. Again I can't understand why this was not promoted
    in the certification process, until now.

    </quote>

    On Fri, 4 Jun 2004 01:11:31 +0200, "Daniel Joskovski"
    <> wrote:

    >Agreed, thanks for suggestion.
    >This is common situation when first try to do something under ASP.NET, if
    >anonymous user access is allowed that mean the user is not authenticated,
    >attempt to obtain trusted connection will fail, but only disallowing
    >anonymous access is not solution, because after that IIS will authenticate
    >ASPNET user account which not have any permission in sql database and it's
    >smart to live that way. To solve problem you need to impersonate ASPNET
    >account to be Your user account ( which account can have trusted connection
    >with SQL server), that can be done in web.config specifying
    ><identity impersonate="true" />
    >
    >Regards,
    >Daniel
    >
    >"The Poster Formerly Known as Kline Sphere" <.> wrote in message
    >news:...
    >> >First uncheck anonymous access in directory security tab of IIS, then in
    >> >web.config put element <impersonate="true"> that will allow to connect to
    >> >SQL server under your account.

    >>
    >> More importantly, the person who posted the original question, should
    >> gain an understand the consequences of such actions,
    >>
    >> Kline Sphere (Chalk) MCNGP #3

    >



    Kline Sphere (Chalk) MCNGP #3
    The Poster Formerly Known as Kline Sphere, Jun 5, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page