PC Review


Reply
Thread Tools Rate Thread

ASPNET won't connect to Northwind

 
 
Harlan Messinger
Guest
Posts: n/a
 
      26th Aug 2006
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?
 
Reply With Quote
 
 
 
 
indrajit.chakrabarty@gmail.com
Guest
Posts: n/a
 
      26th Aug 2006

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

 
Reply With Quote
 
Harlan Messinger
Guest
Posts: n/a
 
      27th Aug 2006
(E-Mail Removed) 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.
 
Reply With Quote
 
indy
Guest
Posts: n/a
 
      27th Aug 2006
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

 
Reply With Quote
 
Harlan Messinger
Guest
Posts: n/a
 
      27th Aug 2006
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.
 
Reply With Quote
 
Harlan Messinger
Guest
Posts: n/a
 
      27th Aug 2006
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can ASPNET access the Northwind database Tony Johansson Microsoft ASP .NET 1 11th Jan 2010 05:54 PM
Is the aspnet account called "aspnet" for all non-English versions of Windows and IIS? torus@tpg.com.au Microsoft ASP .NET 7 23rd Mar 2007 04:00 AM
Upgrade from aspnet 1.1 to aspnet 2.0 Gary Nelson Microsoft ASP .NET 2 14th Oct 2005 06:16 PM
Changing DataViewManager.RowFilter has no effect - Sample Northwind Code Attached - Northwind.zip (0/1) Jay Pondy Microsoft Dot NET Framework Forms 0 12th Feb 2005 12:24 PM
Northwind Mike Microsoft Access Database Table Design 3 21st May 2004 03:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:04 PM.