Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > ASPNET won't connect to Northwind

Reply
Thread Tools

ASPNET won't connect to Northwind

 
 
Harlan Messinger
Guest
Posts: n/a
 
      08-25-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.d sCustomers1)).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
 
      08-26-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
 
      08-27-2006
http://www.velocityreviews.com/forums/(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
 
      08-27-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
 
      08-27-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
 
      08-27-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

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 ASP .Net 1 01-11-2010 05:54 PM
ASPNET won't connect to Northwind Harlan Messinger ASP .Net 5 08-27-2006 01:10 PM
Installer example in northwind or duwamish7? Bright ASP .Net 1 07-18-2005 05:50 PM
Where can I get NorthWind sample application? Bright ASP .Net 2 07-16-2005 12:18 AM
RE: Northwind based ASP.NET Demo Chris Moore ASP .Net 0 04-17-2004 12:53 AM



Advertisments