Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : in C# and VB 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 5th, 2014, 04:51 PM
Registered User
Points: 28, Level: 1
Points: 28, Level: 1 Points: 28, Level: 1 Points: 28, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2014
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Question Chapter 13, and double clicking database

I am using SQLExpress since it has been on my computer for a while and LocalDB won't install over higher versions.

On page 458 Step 6 we are supposed to double-click the PlanetWrox.mdf database.

When I did that I got an error that said it was 'Unable to open the physical file... etc.' I made sure it wasn't open anywhere else, and that I was running the programs as Administrator, and that I created the database as Administrator.

However, when I created the SqlDataSource manually, I was able to proceed onto the next steps.

Do I really have to uninstall SQLExpress and load in the LocalDB program to get this to work or is there something else going on?

On page 463 Step 2, I dragged a DetailsView onto the page where it was supposed to go, but the code that was created did not match the description in step five. There was no DataKeyNames="ID" and no AutoGenerateRows="False" in the code.

Also the ID was visible on the page along with the Name and SortOrder fields.

Would this also be caused by SQLExpress rather than the LocalDB engine?

Thanks.

By the way, I have given Mr. Spaanjaars high praise in Amazon for his book, it's one of the best books on Web Sites I have read in a long time.
Reply With Quote
  #2 (permalink)  
Old May 6th, 2014, 04:27 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Tony,

Quote:
Do I really have to uninstall SQLExpress and load in the LocalDB program to get this to work or is there something else going on?
Nope; Express works as well. Local DB is just the new way of doing things as it's more light-weight and easier to use.

Quote:
There was no DataKeyNames="ID" and no AutoGenerateRows="False" in the code.

Also the ID was visible on the page along with the Name and SortOrder fields.

Would this also be caused by SQLExpress rather than the LocalDB engine?
Nope. Both use the same database engine so the result should be the same. It sounds more like you haven't set the Id column to be the primary key and the Identity in the database designer.

Quote:
By the way, I have given Mr. Spaanjaars high praise in Amazon for his book, it's one of the best books on Web Sites I have read in a long time.
Thanks!!
Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old June 11th, 2014, 01:53 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2014
Location: Derby, United Kingdom
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I too am finding it difficult adding the database to the site, i followed all the steps in the book (i think...) I can't see where in the book it says i have to "Run as Administrator"?
To get it to work though i had to detach the database from the sqlexpress instance, but doing that i randomly get error 5 access is denied, i have replaced all the permissions on folder and file and it still keeps happening.
under the server explorer the db has a red x through it and i have to refresh to get the green plug?
Basically what i am asking is:
1. Should i have opened SSMS as admin AND opened VSW as admin?
2. Does the database need to be detached from the instance?

any help would be greatly appreciated.
Reply With Quote
  #4 (permalink)  
Old June 11th, 2014, 02:51 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Lee,

Are you using SqlExpress or LocalDB? Both should work, and neither should require you to run as an Administrator

Does it work when you detach from SQL Server in Management Studio, restart Visual Studio and then double-click the database file in the App_Data folder?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #5 (permalink)  
Old June 11th, 2014, 03:44 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2014
Location: Derby, United Kingdom
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Many thanks for the prompt reply.

The instance i am using is SQLExpress.

It works if i detach the db, but the connection string contains localDB and that isn't the instance it was created in?

Regards
Lee
Reply With Quote
  #6 (permalink)  
Old June 11th, 2014, 03:47 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Lee,

Both SQL Express and Local DB can work with databases that are attached on the fly using the AttachDbFilename attribute in the connection string. Local DB is meant for development, so I would favor that over Express when you have the chance.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #7 (permalink)  
Old June 11th, 2014, 03:56 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2014
Location: Derby, United Kingdom
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Sorry for being a pain.
so it is correct that i have to detach the database after creating in SSMS in order to be able to use it in VSW?
Does the below connection string look correct? as i keep getting a red x through my connection or is that supposed to happen?

Code:
  <connectionStrings>
    <add name="PlanetWroxConnectionString1" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\PlanetWrox.mdf;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
Many thanks
Lee
Reply With Quote
  #8 (permalink)  
Old June 11th, 2014, 04:06 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

It depends on how you attached it, but yes, detaching it from SQL Server Express in Management Studio should help. It releases the locks on the physical MDF file so Local DB can then access the files.

And yes, that connection string looks fine. It's identical to the one I used in the book.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
LeeMorgan (June 11th, 2014)
  #9 (permalink)  
Old June 11th, 2014, 04:17 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2014
Location: Derby, United Kingdom
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Ah ok.... i think i get it now.
If i had created the db in the localDB instance VSW would have been able to access it without me detaching it because it is the same engine.

if i don't want to detach it then i have to use the sql server explorer and drag the table from that instance?

I really appreciate all of your help, keep up the good work, this book is one of the best written and easy to follow books i have read. :)

Lee
Reply With Quote
  #10 (permalink)  
Old June 12th, 2014, 05:05 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yes, that pretty much sums it up.

>> this book is one of the best written and easy to follow books i have read. :)

Thanks!

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


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
Problem with double clicking on the button ranking system nir987 ASP.NET 3.5 Professionals 3 November 23rd, 2011 09:25 PM
Double Clicking The Blank Area of a ListBox southernsun VB How-To 3 December 11th, 2009 10:15 AM
Double clicking control does not add code to Code Behind Paul Walton BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 September 25th, 2009 05:40 PM
Expanding TreeView from double clicking ListView maxl Pro Visual Basic 2005 1 March 5th, 2007 12:54 PM
Chapter 13 - Storing Inf in a Database phudong3da Dreamweaver (all versions) 1 April 22nd, 2005 01:00 AM



All times are GMT -4. The time now is 05:08 PM.


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