Wrox Programmer Forums
|
ASP E-commerce As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP E-commerce section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2003, 11:32 AM
Registered User
 
Join Date: Jun 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Database in SQL server connection failed...

Hello,

I wondering if someone can help me for this error msg.

I am in Chapter 3, page 91 of Beginning ASP.NET E-Commerce book.I follow the book exactly. Only two exceptions, I designed the database in SQL server and run uner window 2000 server and my web.config file contains this:

  <appSettings>
    <add key="ConnectionString" value="Server=(local);integrated security=sspi;Initial Catalog=WroxJokeShop" />
  </appSettings>

I didn't set up user name and password for login in to SQL server database. I set up it as windows Authentication mode so don't need the user name and password. My computer name is "HOME". My SQL Server name is "(local)

Now I got an error below when I run the default.aspx file. It could be connectionString problem. What have you seen? Let me know how should I correct it, if you see the problem is and know the answer. I will be very much appreciated your help.


Diana ([email protected]

Server Error in '/WroxJokeShop' Application.
--------------------------------------------------------------------------------

Login failed for user 'HOME\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'HOME\ASPNET'.

Source Error:


Line 11:
Line 12: ' Open the connection
Line 13: connection.Open()
Line 14:
Line 15: ' Return a SqlDataReader to the calling function


Source File: C:\BEgEcom\WroxJokeShop\BusinessObjects\Catalog.vb Line: 13

Stack Trace:


[SqlException: Login failed for user 'HOME\ASPNET'.]
   System.Data.SqlClient.SqlConnection.Open()
   WroxJokeShop.Catalog.GetDepartments() in C:\BEgEcom\WroxJokeShop\BusinessObjects\Catalog.vb :13
   WroxJokeShop.DepartmentsList.Page_Load(Object sender, EventArgs e) in C:\BEgEcom\WroxJokeShop\UserControls\DepartmentsLi st.ascx.vb:39
   System.Web.UI.Control.OnLoad(EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain()




Diana
 
Old July 12th, 2003, 11:41 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

By default, when using integrated security, ASP.NET will use the ASPNET account to connect to SQL Server.

To allow this, you'll need to give the MachineName\ASPNET account at least login access to your database and enough permissions to read (and update / delete) data in the database. You can do this through the Enterprise Manager of SQL Server. First, open the Security node and then Logins and add the the ASPNET account. Give it access to your WroxJokeShop database.

Then in that database, fine-tune the rights the account needs for the application.

Alternatively, you can use Impersonation. There are quite a lot of articles available on the MSDN site on this topic. For example:

http://msdn.microsoft.com/library/de...ersonation.asp

and

http://msdn.microsoft.com/library/de...onsecurity.asp

Search the MSDN site for Impersonation and ASP.NET for more information on this subject.

Hth

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old July 12th, 2003, 12:18 PM
Registered User
 
Join Date: Jun 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, Imar. I will check on it.

Diana

Diana
 
Old July 25th, 2003, 02:48 AM
Authorized User
 
Join Date: Jul 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You may want to make sure that your websites Directory Security settings in IIS have anonymous access unchecked. Compare your site by looking at the gadgetwarehouse IIS settings, by bringing up Properties when your in Internet Information Services, goto Directory Security, click Edit under Annonymous access and authentication control, then check to see if the Annonymous access check box is checked or not. For your site to work properly you may need to have the check box unchecked.
 
Old August 9th, 2003, 07:42 PM
Registered User
 
Join Date: Aug 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had the same problem but was able to resolve by changing the authentication mode. Additionally, here is the connection used within web config:

<add key="ConnectionString" value="Server=(local)\VSdotNET;User ID='sa';Password=;trusted_connection='yes';Initial Catalog=WroxJokeShop" />

[u]CAUSE</u>The default authentication mode for MSDE 2000 is Windows Authentication. MSDE 2000 installs with a built-in system administrator (SA) user account. However, because SQL Server Authentication is disabled by default, you cannot access the built-in account after a typical installation.

Read this article

[u]285097</u> INF: How to Change the Default Login Authentication Mode to SQL While Installing SQL Server 2000 Desktop Engine by Using Windows Installer

http://support.microsoft.com/default...b;EN-US;285097

Edit registry to change to mixed mode:

Navigate to the following registry key for a named instance:

HKLM\Software\Microsoft\Microsoft SQL Server\Instance Name\MSSQLServer\LoginMode

On the right-hand pane, find the value LoginMode and double-click it.
In the DWORD Editor window, set the value to 2. Also, make sure that the Hex radio button is selected.

Stop and start MSDE sql server. Try running again; it should work.
 
Old August 20th, 2003, 12:53 PM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was so pleased with finally connecting to my database for the GadgetsWarehouse demo site from ASP.NET E-Commerce, that I have to add -

if all else fails, try chaning your connection string to:
"user id=sa; password=; database=GadgetsWarehouse; server=HEATHFIE-HCWP5G;"

make sure you have mixed security settings i.e.
on SQL Server Enterprise manager, right click server node (under server group), select properties, select security tab, under "Authentication:" select "SQL Server and Windows" radio button.



 
Old August 20th, 2003, 12:54 PM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

whoops, dont use the same server name... just note id=sa, password=;

 
Old August 21st, 2003, 03:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by khalidsafir
 I was so pleased with finally connecting to my database for the GadgetsWarehouse demo site from ASP.NET E-Commerce, that I have to add -

if all else fails, try chaning your connection string to:
"user id=sa; password=; database=GadgetsWarehouse; server=HEATHFIE-HCWP5G;"

make sure you have mixed security settings i.e.
on SQL Server Enterprise manager, right click server node (under server group), select properties, select security tab, under "Authentication:" select "SQL Server and Windows" radio button.
This is fair enough for the purpose of learning this stuff - you just want to get on with the code, not get bogged down trying to connect to a database. But just be aware that you would never connect as 'sa' in a production environment, especially if you have no password on your sa account - its just a massive security risk.

rgds
Phil
 
Old December 5th, 2003, 01:43 PM
Authorized User
 
Join Date: Oct 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok i cant connect same problem as above

how can i creat a login name and password for the database???
i cant find any manager or anything else!!!

 
Old December 5th, 2003, 02:52 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

What database are you using? Did you install the MSDE instead of a full version of SQL Server?

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server Connection and Database Problem workib C# 1 November 13th, 2008 03:26 PM
Database connection with SQL Server yubaraj JSP Basics 3 May 29th, 2007 04:39 AM
Failed to copy objects from SQL server to SQL Serv monfu SQL Server 2000 4 December 4th, 2005 05:54 PM
Database connection failed after SP2 Ned VB Databases Basics 0 August 31st, 2004 02:59 PM
Sql server connection failed AcidHell2 All Other Wrox Books 0 February 26th, 2004 01:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.