ASPNET won't connect to Northwind

H

Harlan Messinger

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?
 
I

indrajit.chakrabarty

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
 
H

Harlan Messinger

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.
 
I

indy

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
 
H

Harlan Messinger

indy said:
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.
 
H

Harlan Messinger

Harlan said:
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.
 

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

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top