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 May 27th, 2009, 11:25 PM
Registered User
 
Join Date: May 2009
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default Chapter 2 "An attempt to attach an auto-named database for file.."

It seems like I made some really stupid mistake somewhere following chapter 2, insert method.
Everything compiles OK but got an error from db.SubmitChanges();
[FONT='Times New Roman','serif']An attempt to attach an auto-named database for file C:\Users….Data_for_VS2008\HRPaidTimeOff.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.[/FONT]
Any Idea?
 
Old May 28th, 2009, 07:17 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Is your database where the connection string says it is? (C:\Users….Data_for_VS2008\HRPaidTimeOff.mdf)

Where in the code did you get the error?
 
Old May 28th, 2009, 08:08 PM
Registered User
 
Join Date: May 2009
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default

This thing drives me nuts.
I already deleted everything, started over, and got same error message.
I am using SQL Express 2008 with Vista Home.
My connection string in app.config HRTimePaidOffDAL looks like:
<connectionStrings>
<addname="V2.PaidTimeOffDAL.Properties.Settings.HRPaidTimeOf fConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\...\ HRPaidTimeOff.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
and pointed to the right location.
I tried to play around with security and User Instance – still getting same error message …
 
Old May 28th, 2009, 08:17 PM
Registered User
 
Join Date: May 2009
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default

And there is only Insert button click event in the code:

protectedvoid btnInsert_Click(object sender, EventArgs e)
{
HRPaidTimeOffDataContext db = newHRPaidTimeOffDataContext();
ENTUserAccount userAccount = newENTUserAccount
{
WindowsAccountName =
@"VARALLO1\VaralloMadison",
FirstName =
"Madison",
LastName =
"Varallo",
Email =
"[email protected]",
IsActive =
true,
InsertDate =
DateTime.Now,
InsertENTUserAccountId = 1,
UpdateDate =
DateTime.Now,
UpdateENTUserAccountId = 1
};
db.ENTUserAccounts.InsertOnSubmit(userAccount);
db.SubmitChanges();
}
 
Old May 28th, 2009, 11:55 PM
Registered User
 
Join Date: May 2009
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default

Finally made it work. But it works only if I put my data base into web site's App_Data folder ...
The Following User Says Thank You to Gredkins For This Useful Post:
stevemonty (July 27th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading a files general property of "Type of file" GregSivers Visual Basic 2008 Essentials 7 June 3rd, 2009 09:38 AM
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM
Chapter 29, The "Simple" Exercise slginps BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1 1 April 25th, 2009 01:40 PM
Chapter-5 on Intents:ContactPickerTester does not show the button "Pick a Contact" sunilm12 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 April 15th, 2009 11:55 AM
Message received by "FILE" adapter is suspended skindika Biztalk 0 February 2nd, 2009 07:06 PM





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