 |
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 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
|
|
|
|
|

May 5th, 2014, 04:51 PM
|
|
Registered User
|
|
Join Date: Apr 2014
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 6th, 2014, 04:27 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 11th, 2014, 01:53 AM
|
|
Registered User
|
|
Join Date: Jun 2014
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 11th, 2014, 02:51 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 11th, 2014, 03:44 AM
|
|
Registered User
|
|
Join Date: Jun 2014
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 11th, 2014, 03:47 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 11th, 2014, 03:56 AM
|
|
Registered User
|
|
Join Date: Jun 2014
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 11th, 2014, 04:06 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

June 11th, 2014, 04:17 AM
|
|
Registered User
|
|
Join Date: Jun 2014
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 12th, 2014, 05:05 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
 |
|