Wrox Programmer Forums
|
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 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 March 31st, 2009, 04:58 PM
Authorized User
 
Join Date: Mar 2009
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default Login failed for database user

Hello,

Today I've just finished up the Administration page and I'm curious to see how this is all shaping up. So I complie and fix any outstanding bugs.

However, now I get a login failure for my database user. I'm using sqlexpress and I've modified the app.config file in the DAL project. However, when I set a break point in the HRPaidTimeOffDataContext I cannot determine where's it's getting the connection string from.

It's showing the ID but not the password

The constructor reads as follows:

Code:
Public Sub New()
MyBase.New(Global.V2.PaidTimeOff.DAL.My.MySettings.Default.HRpaidTimeOffConnectionString1, mappingSource)
OnCreated
End Sub
But the return value is not what's in the config file. Can someone point me in the right direction?

Thanks,
realkewl

Last edited by realkewl; March 31st, 2009 at 04:59 PM.. Reason: spelling
 
Old March 31st, 2009, 08:20 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

The sample that comes with the book expects the connection string to be in the web.config file in the web site project.
The code you're showing is for the default constructor of the DataContext. This would only be called if you didn't pass in the connection string when the DataContext is instantiated.

The sample code passes in the connection string to the constructor using a helper function in the DBHelper class.

Code:
using (HRPaidTimeOffDataContext db = new HRPaidTimeOffDataContext(DBHelper.GetHRPaidTimeOffConnectionString()))
 
Old March 31st, 2009, 08:59 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

I just noticed a bug on Page 44. The code in the book calls the HRPaidTimeOffDataContext's default constructor but it shouldn't. It should use the following line in the using statement.

Code:
using (HRPaidTimeOffDataContext db = newHRPaidTimeOffDataContext(DBHelper.GetHRPaidTimeOffConnectionString()))


This could be what was causing your problem because instead of looking to the web.config file for the connection string it would be looking at your settings file.
 
Old April 1st, 2009, 11:02 AM
Authorized User
 
Join Date: Mar 2009
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks that does explain a couple of things. For the moment I just added the connection string to the web.config and it does work. BTW I could not find mention of the DBHelper class in Chapter 2, however I did find the class in your source code in chapter 4.

-realkewl
 
Old June 18th, 2009, 05:34 PM
Registered User
 
Join Date: Jun 2009
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Default

hello
I had the same problem and solved it as follows.
code in the web.config
Code:
<connectionStrings>
    <add name="HRPaidTimeOffCON" connectionString="Data Source=LAPTOP\SQLEXPRESS;Initial Catalog=HRPaidTimeOff;User ID=sa;PASSWORD=XXXXXXX;Pooling=False"/>
  </connectionStrings>
and the code-behind:

Code:
HRPaidTimeOffDataContext db = new HRPaidTimeOffDataContext(ConfigurationManager.ConnectionStrings["HRPaidTimeOffCON"].ToString());
The key is to call the connectionstring (with the correct name) and use the ConfigurationManager.connectionStrings. I try to use DBHelper, and was impossible.





Similar Threads
Thread Thread Starter Forum Replies Last Post
login script: user can't hit "return" for login dmerrill Java Basics 13 July 14th, 2006 07:25 PM
login failed for user domain\user babakwx SQL Server 2000 2 May 30th, 2006 12:28 PM
Newbie Help. Login to unique login page per user Kainan Classic ASP Professional 10 May 3rd, 2005 07:47 AM
login failed for user nt authority\anonymous login rj1406 Classic ASP Databases 1 October 24th, 2004 09:15 AM





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