ASPNET won't connect to Northwind

Discussion in 'ASP .Net Datagrid Control' started by Harlan Messinger, Aug 26, 2006.

  1. I installed the Northwind database in my SQL Server developer version,
    added [MyMachine\ASPNET] to the server logins, and in OSQL ran

    use Northwind
    GO

    grant all to [MyMachine\ASPNET]
    GO

    These executed without error. But my test page is being denied access.

    Learning to bind a datagrid to a SQL table for the first time, after
    creating the connection and the adapter and all that, my code-behind
    class has, in InitializeComponent:

    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
    this.dsCustomers1 = new _315c05.dsCustomers();
    ((System.ComponentModel.ISupportInitialize)(this.dsCustomers1)).BeginInit();

    and, later,

    this.sqlConnection1.ConnectionString = "workstation id=MYMACHINE;packet
    size=4096;integrated security=SSPI;data source=MYM" +
    "ACHINE;persist security info=False;initial catalog=Northwind";

    followed by a bunch of mappings.

    In Page_Load I have

    sqlDataAdapter1.Fill(dsCustomers1, "Customers");
    dgCustomers.DataBind();

    Finally, my datagrid has DataSource set to dsCustomers1, DataMember set
    to Customers, and DataKeyField set to CustomerID.

    When I run the page, I get an error on the DataFill call:

    Cannot open database requested in login 'Northwind'. Login fails. Login
    failed for user 'MYMACHINE\ASPNET'.

    I can see the contents of the Customers table just fine if I
    double-click on it under the Data Connections section of Server Explorer
    in Visual Studio.

    Any ideas?
    Harlan Messinger, Aug 26, 2006
    #1
    1. Advertising

  2. Harlan Messinger

    Guest


    >
    > and, later,
    >
    > this.sqlConnection1.ConnectionString = "workstation id=MYMACHINE;packet
    > size=4096;integrated security=SSPI;data source=MYM" +
    > "ACHINE;persist security info=False;initial catalog=Northwind";
    >


    Seems that you have missed - "Provider=SQLOLEDB.1"...

    Right-click on the connection in Visual Studio and select "Properties",
    and check the entry for "ConnectString" in the list.

    HTH,
    indy
    , Aug 26, 2006
    #2
    1. Advertising

  3. wrote:
    >> and, later,
    >>
    >> this.sqlConnection1.ConnectionString = "workstation id=MYMACHINE;packet
    >> size=4096;integrated security=SSPI;data source=MYM" +
    >> "ACHINE;persist security info=False;initial catalog=Northwind";
    >>

    >
    > Seems that you have missed - "Provider=SQLOLEDB.1"...
    >
    > Right-click on the connection in Visual Studio and select "Properties",
    > and check the entry for "ConnectString" in the list.


    Thanks, but when I insert that into the connection string for
    sqlConnection1 (with a semicolon afterwards) I get an error dialog,
    Invalid Property Value. "Keyword not supported: 'provider'."

    Googling this, I find that the Provider string is redundant because I'm
    already using a SqlConnection. I would need it if I were using an
    OleDbConnection.
    Harlan Messinger, Aug 27, 2006
    #3
  4. Harlan Messinger

    indy Guest

    Your initial post didn't mention which version of VS you are using. I
    assumed that you were working through the examples in Amit Kalanis'
    70-315 book!

    I suggest you download and install Microsoft SQL Server Management
    Studio Express - . It is freeware, and provides a very handy interface
    to any SQL Server MSDE/SQL Server 2000 instance and SQL Sever 2005 /
    SQL Server 2005 Express instance on your PC. After you connect to the
    SQL Server in question, expand "Security", then "Logins". Since you
    have added the ASPNET account, check the permissions of the user on the
    Northwind database (Note that the above can be done by manually typing
    in the right commands).


    I am sure it is an issue with permissions on the database for the
    ASPNET user.

    HTH,
    indy
    indy, Aug 27, 2006
    #4
  5. indy wrote:
    > Your initial post didn't mention which version of VS you are using. I
    > assumed that you were working through the examples in Amit Kalanis'
    > 70-315 book!


    Correct! And it's VS 2003, .NET 1.1.

    >
    > I suggest you download and install Microsoft SQL Server Management
    > Studio Express - . It is freeware, and provides a very handy interface
    > to any SQL Server MSDE/SQL Server 2000 instance and SQL Sever 2005 /
    > SQL Server 2005 Express instance on your PC. After you connect to the
    > SQL Server in question, expand "Security", then "Logins". Since you
    > have added the ASPNET account, check the permissions of the user on the
    > Northwind database (Note that the above can be done by manually typing
    > in the right commands).


    Thanks for the tip.
    Harlan Messinger, Aug 27, 2006
    #5
  6. Harlan Messinger wrote:
    > indy wrote:
    >>
    >> I suggest you download and install Microsoft SQL Server Management
    >> Studio Express - . It is freeware, and provides a very handy interface
    >> to any SQL Server MSDE/SQL Server 2000 instance and SQL Sever 2005 /
    >> SQL Server 2005 Express instance on your PC. After you connect to the
    >> SQL Server in question, expand "Security", then "Logins". Since you
    >> have added the ASPNET account, check the permissions of the user on the
    >> Northwind database (Note that the above can be done by manually typing
    >> in the right commands).

    >
    > Thanks for the tip.


    Well, I found that I had created a user called Northwind in the master
    database, and nothing in the Northwind database. That, even though I'd
    gone through the GRANT exercise twice, as described in my original
    message. I don't get it, but the Management Studio let me do what I
    needed to. I hadn't known you could get that for free, so I'm grateful
    for the pointer.
    Harlan Messinger, Aug 27, 2006
    #6
    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.
Similar Threads
  1. Bright
    Replies:
    2
    Views:
    4,004
    Bright
    Jul 16, 2005
  2. Bright
    Replies:
    1
    Views:
    533
  3. Chris Moore

    RE: Northwind based ASP.NET Demo

    Chris Moore, Apr 17, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    516
    Chris Moore
    Apr 17, 2004
  4. Harlan Messinger

    ASPNET won't connect to Northwind

    Harlan Messinger, Aug 26, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    446
    Harlan Messinger
    Aug 27, 2006
  5. Tony Johansson

    How can ASPNET access the Northwind database

    Tony Johansson, Jan 7, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    1,264
    Alvin Bruney - ASP.NET MVP
    Jan 11, 2010
Loading...

Share This Page