Results 1 to 11 of 11

Thread: connection string

  1. #1

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    connection string

    hi to everyone its me again..
    [php]
    questioning the endlesses questions...
    i have a connection string in vb.net application and it works fine..
    [/php]
    but when i use this connection to asp.net it throws an error: System.Data.SqlClient.SqlException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
    VB Code:
    1. Dim cn As New SqlConnection("integrated security=true;initial catalog=northwind;data source=local host")

    what im i missing in asp.net???
    im very new in this thing since this is my first approach on asp.net..

    pls. help...

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Extra! Extra! Get your connection strings here:

    www.able-consulting.com/ado_conn.htm

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Extra! Extra!

    Get your other connection strings here:
    www.connectionstrings.com

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Connection string aside, am I the only one who finds it odd that it said failed login (null) - which tells me there's no user context, and since he's using trusted security.... that's why it failed. There's no user context from which to connec to the database with.


    TG
    Last edited by techgnome; Sep 1st, 2004 at 04:58 PM.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Is the SQL Servers security setup to use Windows Authentication of SQL Server Authentication?
    If SQL Server Authentication, then it would expect a username and password in the connectionstring.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by Memnoch1207
    Is the SQL Servers security setup to use Windows Authentication of SQL Server Authentication?
    If SQL Server Authentication, then it would expect a username and password in the connectionstring.
    That's true. The connection string does say "integrated security=true;" which tells me WinNTAuth is to be used, - but that doesn't mean the server is set up that way. I don't know under what context the page is running. Obviously, what ever user context (if any) the code is running under, that user doesn't have permissions. Since it reported the login as (null) I have to assume that it isn't running under any user context. In which case it needs to be converted over to use SQL authentication, in which case the connection string would need to be changed, or the code needs to be forced to run under a specific user context that has the appropriate security to access the database.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    thanks guys for the reply..i tried what you have suggested if it works..


    more power..

  8. #8
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    If you want to use windows authentication, you need to turn off anonymous access in IIS. If that is checked, windows credentials won't be passed on to ASP.NET.

  9. #9

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    thanks hellswraith for the reply..
    actually i already solve this scenario..
    i just add new login (computername\Aspnet) and it do the trick..

    hey sorry for my stupidity im very new in this thing and i just want to know if asp.net allow global declarations..ie. i want ot declare my connection in global so that i can access it everywhere..



    thanks in advance mate..
    more power..




    :mike: RIP

  10. #10
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Store your connection string in the web.config file. Add a section that looks like this (search on the web for more info):

    <appSettings>
    <add key="ConnectionString" value="your long connectionstring here" />
    </appSettings>

    Then, anywhere in your app, you can do a
    MyString = System.Configuration.ConfigurationSettings.AppSettings("ConnectionString")

  11. #11
    New Member
    Join Date
    May 2004
    Location
    Manchester England
    Posts
    11

    Re: connection string

    Hello
    I am having the same problem and I have read this thread over and over again and i just cant see how Iam supposed to resolve it. I might be being stupid but please have patience.

    Thanks for you time
    Thanks
    Neal

Posting Permissions

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



Click Here to Expand Forum to Full Width