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 > ASP.NET 4 General Discussion
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion 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 November 14th, 2010, 02:35 AM
Authorized User
Points: 150, Level: 2
Points: 150, Level: 2 Points: 150, Level: 2 Points: 150, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Location: Perth, Western Australia
Posts: 33
Thanks: 7
Thanked 1 Time in 1 Post
Send a message via MSN to cuddling101 Send a message via Yahoo to cuddling101
Question 'System.InvalidOperationException' and 'Instance failure'

I am having difficulty at the stage of mapping data model to an entity model. I have honestly lost track a little here. I thought that I had it basically working but I am not sure. There was an issue arose where I had 'provider connectionstring' instead of 'provider connection string', but I corrected that, thanks to Imar's input. I have then come to wanting to update my Entity Data Model and I have hit various problems.

As I had got confused, I sought to delete all the stuff (maybe I deleted too much), that the process outlined on pages 481-3 of Beginning ASP.NET 4 had created, including the Entities line in web.config, and to restart the process at point 1 on page 481, but I am now receiving the message -

Code:
An error occurred while connecting to the database.  The database might be unavailable.  An exception of type 'System.InvalidOperationException' occurred.  The error message is: 'Instance failure.'.
This occurs when I try to go from Step 3 to Step 4, i.e, go on to where I will be adding Tables to the model.
In another post in these forums about ASP.NET.4, I found the following comment –

Quote:
USERNAME\AppData\Local\ Microsoft\Microsoft SQL Server Data\SQLEXPRESS. It was amazing to see all the new folders in the path showing up and expanded.

After I deleted the files in this folder I was finally able to see the database and all its files under the project Data Connections.
I wondered whether this had some relevance. I see that my version of this file contains a file named Entropy.bin, some error.log files, some log.trc files and 3 pairs of .mdf and .ldf files, which are named master.mdf, mastlog.ldf, msdbdata.mdf, msdblog.ldf, tempdb.mdf, and templog.ldf. Being uncertain as to what these are, I am hesitant to delete them, for fear of causing even more problems.

I am able to see the database quite happily in SSMS. I have been working on the database in there over the last few days. I have been updating contents and adding tables.

Any ideas re what to look for, or step I should go back to (in order to check that I haven't 'corrupted' things), would be very welcome, please.

Please do ask for more code 'input' if you need it, in order to help.

With thanks in anticipation

Philip Hunt'
Medina, Kwinana
Perth, Western Australia
Reply With Quote
  #2 (permalink)  
Old November 14th, 2010, 07:19 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Philip,

Can you post your connection string?

Also, can you try moving the SQL Express folder and see if that fixes things? That way, it's easy to restore the files if removing them doesn't fix it.

Quote:
step I should go back to (in order to check that I haven't 'corrupted' things),
This isn't so much "steps in the book" related; it sounds like an issue with SQL Server Express which needs to be solved separately before you can create and use a model.

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 November 14th, 2010, 10:28 AM
Authorized User
Points: 150, Level: 2
Points: 150, Level: 2 Points: 150, Level: 2 Points: 150, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Location: Perth, Western Australia
Posts: 33
Thanks: 7
Thanked 1 Time in 1 Post
Send a message via MSN to cuddling101 Send a message via Yahoo to cuddling101
Default Connection Strings from web.config

Hello Imar

Thank you for your help.

The following is the connnection strings section of my web.config.

It';s getting late here now, so I will try the SQL Express folder move stuff tomorrow evening after work.

Code:
  <connectionStrings>
    <clear />
    <add name="How_and_Why_Wonder_BooksConnectionString1" connectionString="Data Source=.\MSSQLSERVER\;Initial Catalog=How_and_Why_Wonder_Books; Integrated Security=True; Connect Timeout = 30;" providerName="System.Data.SqlClient" />
    <add name="LocalSqlServer" connectionString="Data Source=.\MSSQLSERVER;Initial Catalog=aspnetdb;Trusted_Connection=True" providerName="System.Data.SqlClient" />
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
    <add name="How_and_Why_Wonder_BooksConnectionString2" connectionString="Data Source=.;Initial Catalog=How_and_Why_Wonder_Books;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
Thank you

Philip
Reply With Quote
  #4 (permalink)  
Old November 14th, 2010, 11:46 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Philip,

I don't see a connection string targeted at EF. You should have one containing stuff like metadata=res://*/

The easiest thing to do probably is to create a new model. Add a new EF Entity Model to your site, follow the wizard and assign a connection string, choose your tables and so on. Then VWD will update your config file with a correct connection string.

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
  #5 (permalink)  
Old November 15th, 2010, 08:08 AM
Authorized User
Points: 150, Level: 2
Points: 150, Level: 2 Points: 150, Level: 2 Points: 150, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Location: Perth, Western Australia
Posts: 33
Thanks: 7
Thanked 1 Time in 1 Post
Send a message via MSN to cuddling101 Send a message via Yahoo to cuddling101
Question

Dear Imar

I thank you for your suggestion to create a new Entity data Model, but that is exactly what I was trying to do that led to the error that started this thread.

As I also explained, I had deleted some things, thinking that would get me back to a 'safe spot' so to say , but all that did was cause more problems.

I have now restored the things I deleted and my web.config file connection strings section now reads -

Code:
  <connectionStrings>
    <clear />
    <add name="How_and_Why_Wonder_BooksConnectionString1" connectionString="Data Source=.\MSSQLSERVER\;Initial Catalog=How_and_Why_Wonder_Books; Integrated Security=True; Connect Timeout = 30;" providerName="System.Data.SqlClient" />
    <add name="How_and_Why_Wonder_BooksEntities" connectionString="metadata=res://*/App_Code.How_and_Why_Wonder_Books.csdl|res://*/App_Code.How_and_Why_Wonder_Books.ssdl:res://*/App_Code.How_and_Why_Wonder_Books.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\MSSQLSERVER;Initial Catalog=How_and_Why_Wonder_Books;Trusted_Connection=True;MultipleActiveResultsSets=True&quot;" providerName="System.Data.EntityClient" />
    <add name="LocalSqlServer" connectionString="Data Source=.\MSSQLSERVER;Initial Catalog=aspnetdb;Trusted_Connection=True" providerName="System.Data.SqlClient" />
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
    <add name="How_and_Why_Wonder_BooksConnectionString2" connectionString="Data Source=.;Initial Catalog=How_and_Why_Wonder_Books;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
I have also restored the .edmx file and its associated designer.vb file, which I had deleted because I thought it might just be best to start again.

That edmx file is named How_and_Why_Wonder_Books.edmx.

What I was actually trying to do, before I got into this whole episode of deleting and redoing, was to update the entity data model.

As shown on page 1114 of Professional ASP.NET 4 I have sought to right click on my Entity Data Model, in order to add a table, just as it shows in that book.

On choosing the option Update Model from Database, I receive the following error message -

Code:
An exception of type
'Microsoft.VSDesigner.Data.Local.ConnectionStringConvertorServiceException' occurred while attempting to update from the database.  The exception message is ''.
When I tried to create a new Object Model, as per the instructions on page 481 of Beginning ASP.NET 4, I got the Instance Failure message that has started this thread. This occurred when I sought to go from step 2 to step 3, that is when I chose the Generate from Database option and clicked Next.

I hope this gives you an appropriate set of extra information that will enable you or your colleagues to come up with ideas for other things to check out.

As I stated at the beginning of this thread, I am able to successfully access the database through SSMS. I use Windows Authentication and I have certainly gone through and checked all the places I have been directed to re permissions etc.

With thanks for all you have done for me and hopes that you might be able to come up with some new avenues of investigation.

Best regards

Philip
Reply With Quote
  #6 (permalink)  
Old November 15th, 2010, 08:39 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You have a mix of .\SqlExpress and .\MSSQLSERVER in your connection strings. Is that by design? Do you have multiple SQL Server instances installed?

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 November 15th, 2010, 10:12 AM
Authorized User
Points: 150, Level: 2
Points: 150, Level: 2 Points: 150, Level: 2 Points: 150, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Location: Perth, Western Australia
Posts: 33
Thanks: 7
Thanked 1 Time in 1 Post
Send a message via MSN to cuddling101 Send a message via Yahoo to cuddling101
Question Mix of connection strings

Dear Imar

It has certainly not been my intention to have two versions of SQL Server running.

This whole MSSQLSERVER v SQLEXPRESS thing is something we have discussed before, and I have never really got completely to the bottom of it or understood it.

I do not consciously have two versions of SQL Express installed or active, but neither do I know how or where I could check for that, or even what I would be looking for to do such checking.

How can I establish which one my SSMS accessible database is running against? How, if I successfully eliminate the references to the incorrect one, do I make sure that VWD doesn't again generate references to the 'dud'?

Thank you for looking at this.

Regards

Philip

Last edited by cuddling101; November 15th, 2010 at 10:13 AM.. Reason: Used wrong word at end of MSSQL...
Reply With Quote
  #8 (permalink)  
Old November 15th, 2010, 10:30 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

If I remember correctly, you didn't have an instance name. In SSMS, you logged into either (local) or . (a single dot).

So, in your connection strings, drop \MSSQLSERVER and \SqlExpress and see if that works. E.g.:

... Data Source=.;Initial ...

Also get rid of the trailing slash you have following MSSQLSERVER

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
  #9 (permalink)  
Old November 17th, 2010, 07:27 AM
Authorized User
Points: 150, Level: 2
Points: 150, Level: 2 Points: 150, Level: 2 Points: 150, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Location: Perth, Western Australia
Posts: 33
Thanks: 7
Thanked 1 Time in 1 Post
Send a message via MSN to cuddling101 Send a message via Yahoo to cuddling101
Default Report re removing MSSQLSERVER and SQLEXPRESS

Dear Imar

I have tried your suggestions and the same error is arising when I try to update the edmx from the database.

Best regards

Philip
Reply With Quote
  #10 (permalink)  
Old November 17th, 2010, 08:04 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

And what happens when you create a brand new web site, add a brand new model and assign a brand new connection string to your database?

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
invalidoperationexception? qiux General .NET 0 January 23rd, 2008 11:39 PM
Insert System date and System Time -Form _TextBox cnkumar74 VB How-To 14 February 14th, 2007 10:52 AM
system.InvalidOperationException furjaw Visual Basic 2005 Basics 0 May 27th, 2006 12:44 AM
Casting System::Object __gc * to System.Double[] nepsat Visual C++ 3 November 19th, 2005 12:51 PM
System.InvalidOperationException: connection dead aleahy General .NET 0 January 28th, 2005 07:58 AM



All times are GMT -4. The time now is 07:37 AM.


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