Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
  #2 (permalink)  
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()))
  #3 (permalink)  
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.
  #4 (permalink)  
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
  #5 (permalink)  
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.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:45 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.