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: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 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 Display Modes
  #1 (permalink)  
Old January 17th, 2010, 11:34 AM
Authorized User
 
Join Date: Jan 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cant get SQL setup correctly

Hi,

getting the following error when trying to run the application as per first chapter:

An attempt to attach an auto-named database for file C:\Websites\WroxUnited\App_Data\WroxUnited.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I have done as follows:
- Already installed Visual Studio 2005 and SQL Server 2005 (both full versions). After reading a few threads here I also installed SQL Express side by side which did not fix my issue (thought I could use the default web.config settings by running both sql versions side by side). It went straight to the error above when trying this.

- I tried manually adding the database to SQL express version and changing the web.config file to use an initial catalogue of the database instead of the attach method already existing, this didnt work. THis resulted in the above error message as well.

- I had tried to manually attach the database to the full sql version and change the web.config settings to reflect which also did not work (I have the full sql version already installed because it is being used by other applications running on my local IIS, so I know the full SQL is working properly as no issues with my other apps). This resulted in the above error message as well.

- I manually removed the database from both sql installs and tried going back to using the standard method as specified in the book, this also produced the above error message.

I have added the network service to the folder with full control, in IIS the application has been assigned the standard application pool.

If anyone can suggest any reasons for this it would be appreciated.

I am running on vista ultimate x64, so trying to get to the documents and settings folder on the local machine is a no go (full admin access login will not allow access to this folder, so have not been able to check the folder location as per the troubleshooting section of the book).

Thanks,

Chris
Reply With Quote
  #2 (permalink)  
Old January 19th, 2010, 04:35 AM
Authorized User
 
Join Date: Jan 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Angry SQL still giving issues

ok,

as per above I have completely removed all SQL server installs, both full sql 2005 and express 2005. I backed up dbs, removed the registry entry and program files for sql server, and reinstalled SQL Express 2005 as well as the management studio for express 2005.

When trying to run the default page of Wrox United application through visual studio 2005, I get the following error in the browser:

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

(further down the page)
Line 109: public virtual string Theme {
Line 110: get {
Line 111: return ((string)(this.GetPropertyValue("Theme")));
Line 112: }
Line 113: set {


When the application was being built in visual studio it also produced this error (within visual studio):

Error 1 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. C:\Websites\WroxUnited\WroxUnited\web.config 41

I am using the asp.net development server through visual studio only, I have also tried doing this with and without a Wrox United website in my IIS.

I also went tried going into SQL configuration manager and changing the SLExpress to use local system instead of network service, but still get the same error message.

Any suggestions?

Thanks,

Chris

Last edited by topher76; January 19th, 2010 at 04:40 AM.
Reply With Quote
  #3 (permalink)  
Old January 19th, 2010, 04:51 AM
Imar's Avatar
Wrox Author
Points: 67,815, Level: 100
Points: 67,815, Level: 100 Points: 67,815, Level: 100 Points: 67,815, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,295
Thanks: 66
Thanked 1,441 Times in 1,421 Posts
Default

Hi there,

The second error may occur when opening an incorrect folder. Try opening the folder that contains the web.config file as a site in VS directly, and not its parent folder.

Also, check Tools | Options Database Tools | Data Connections

There you can set the default instance name for VS to use.

When you use something like Management Studio, can you connect to .\SqlExpress? How do your connection strings look? Did you make any changes to the LocalSqlServer connection string?
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
  #4 (permalink)  
Old January 19th, 2010, 05:45 AM
Authorized User
 
Join Date: Jan 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Just to confirm, I am using the actual WroxUnited folder that contains the web.config folder as the root folder for the web site, there is no parent folder involved.

I have used both the default string for the db connection (./SQLExpress), as well as Topher/SQLExpress (Topher being the machine name). Both have resulted in the same error as mentioned previously.

The options setting for the default db connection is set to SQLExpress in VS, should I change this to Topher/SQLExpress as well?

The connection string from the web.config file currently is:
<connectionStrings>
<add name="WroxUnited"
connectionString="Data Source=Topher\SQLEXPRESS;AttachDbFilename=|DataDir ectory|WroxUnited.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

***for some reason there appears to be a space in datadirectory above, this is the formatting of the forum, my actual code has no spaces.

I have made sure the network service has full access on the root folder and all child folders for the web site. I have also added the network service as a login in sql as well just to be sure, although not sure if that is necessary.

Thanks for your help.

Chris

Last edited by topher76; January 19th, 2010 at 05:50 AM.
Reply With Quote
  #5 (permalink)  
Old January 19th, 2010, 05:59 AM
Imar's Avatar
Wrox Author
Points: 67,815, Level: 100
Points: 67,815, Level: 100 Points: 67,815, Level: 100 Points: 67,815, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,295
Thanks: 66
Thanked 1,441 Times in 1,421 Posts
Default

There are a couple of things you can try / check:

1. Make sure you can connect to your SqlExpress installation using SQL Server Management Studio. This would be the first thing I'd check.

2. Attach your databases to SQL Server and change AttachDbFilename to Initial Catalog: http://www.connectionstrings.com/sql-server-2005

3. Make sure user instances are enbaled: http://msdn.microsoft.com/en-us/libr...04(VS.80).aspx

4. Try dropping User Instance from the connection string


And maybe the problem is not in your own connection string / database but in the one defined in machine,config (called LocalSqlServer and used for Profile, Membership and so on)
Quote:
The options setting for the default db connection is set to SQLExpress in VS, should I change this to Topher/SQLExpress as well?
Nope; SQLExpress is fine....

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
  #6 (permalink)  
Old January 20th, 2010, 01:24 AM
Authorized User
 
Join Date: Jan 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

thanks again for your help with this, I completed your suggestions which had the following results:

- when connecting to the sql management studio express it allows me to connect via windows authentication no problem, but it will not allow sql server authentication connection. It produces an error if I try this "connection successfully established with server, but error occurred during the login process. (No process on the other end of the pipe, microsoft sql server error 233)". Looking at forums for this error suggestions came back saying to use the surface area configuration to allow remote connections which I did, when logging in with my admin account after that it produced and error saying the user is not associated with a trusted sql server connection. I have not attempted anything else beyond this point although I did assign my admin account as db_owner of the wroxunited database (when i access the management studio through the windows authentication method).

- Tried attaching the database and connecting via the trusted sql connection string as you suggested via the link, this produces the same error as before "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed." I wasnt sure what username and password to use if specifying the uid and pwd in the string as I cant login through management studio with a username and password at this stage.

- I ran the instance enabling command which replied saying it changed from a value of 1 to 1. Then said it would take effect after running the reconfigure option (I ran a 'reconfigure' command which executed successfully after this, not sure if the reconfigure command is meant to be more detailed than that).

- In the connection string I have tried changing to:
connectionString="Server=Topher; Database=WroxUnited; Integrated Security=SSPI;"
but this has not had any effect either.

I am also still getting an error in the debugging part of the application which says "It is an error to use a section registered as allowDefinition='MachinetoApplication' beyond the application level. This error can be caused by a virtual directory not being configured as an application in IIS. - web.config - line 41". Not sure why there is an error being generated from IIS seeing as I am using the internal asp.net dev server to run the application, would this have any effect with the database connection if it has somethig to do with a virtual directory not being conifgured properly?

Sorry for the back and forth with this, not too savvy on the sql side, thanks again for your help.

Cheers,

Chris
Reply With Quote
  #7 (permalink)  
Old January 20th, 2010, 03:20 AM
Imar's Avatar
Wrox Author
Points: 67,815, Level: 100
Points: 67,815, Level: 100 Points: 67,815, Level: 100 Points: 67,815, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,295
Thanks: 66
Thanked 1,441 Times in 1,421 Posts
Default

Quote:
when connecting to the sql management studio express it allows me to connect via windows authentication no problem, but it will not allow sql server authentication connection
This is not necessarily a problem. It just indicates that SQL Server is not configured for SQL Server authentication. Check out this article for more information about the two authentication mechanisms.

http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=395

Quote:
I wasnt sure what username and password to use if specifying the uid and pwd in the string
You shouldn't specify one if you're using Windows Authentication (a Trusted Connection) as in that case your own Windows account is used.

Quote:
connectionString="Server=Topher; Database=WroxUnited; Integrated Security=SSPI;"
Your instance is called SqlExpress, right? So you need to connect to .\SqlExpress or Topher\SqlExpress. Are you sure you're connecting to the same and correct instance (SqlExpress) every time?

Quote:
It is an error to use a section registered as allowDefinition='MachinetoApplication' beyond the application level
You get this error when you try to override settings at a folder level which are meant to be set at the application level. For example, consider this:

Code:
- C:\
  - Sites
    - YourSite
      - Default.aspx
      - Web.config
You get the error when you open C:\Sites as the web site in Visual Studio and then browse to http://localhost/YourSite.
You may also get the error when your web.config contains settings it's not allowed to override. How is your site structured and what folder are you opening in Visual Studio?

You may find the article I linked to useful as it provides a lot of detail about connecting to SQL Server from a web application.

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
  #8 (permalink)  
Old January 22nd, 2010, 01:23 PM
Authorized User
 
Join Date: Jan 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

ok, tried a lot of different things over the past two days, here goes.

When accessing the server explorer in VS I was not able to get any connections to the sql server with any instances, server names, etc... absolutely nothing, even though i could connect through management console. I tried to register the sql server through a .net gui which actually generated some error relating to IIS not being installed properly.

I completely removed SQL (inc. registry and program files folders), removed IIS and also replaced the core code and application that i downloaded from the wrox site.

I also discovered that somehow in the application a second subfolder was created that also had a web.config file in it (c:\websites\wroxunited\wroxunited\web.config). This is now gone as I replaced the core application where it is now located at c:\wrox\wroxunited.

After removing sql and IIs, I did a full reinstall of IIS and SQL 2005 standard edition. When installing SQL I chose windows authentication, and for all services to run as network service (instead of default local system as I thought asp.net used the network service process, correct me if I am wrong). I then attached the WroxUnited database successfully.

When I open VS server explorer I can now connect to the local server and I can make a data connection to the WroxUnited database successfully.

However when I run the application I still get an error as follows:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

It is strange that it is doing this even after a successful connection in the server explorer data connections section. If I go to database tools, the instance field is blank to indicate the default instance of the server.

I have tried the following connection strings with no luck:

connectionString="Server=Topher; Initial Catalog=wroxunited; Integrated Security=SSPI;"
--and--
connectionString="Data Source=Topher; Initial Catalog=wroxunited; Integrated Security=SSPI;"
--and--
Data Source=TOPHER;Initial Catalog=WroxUnited;Integrated Security=True

The last one confuses me as well as this is the direct connectionstring from the properties of the successful data connection that I made in server connections through VS.

So in a nutshell, server explorer data connection is successful to the database (I can view all tables and so on), but the application does not see the server at all and will not make a connection.

I want to throw my laptop out the window, but persistence will pay off (hopefully).

Any ideas?

Thanks,

Chris
Reply With Quote
  #9 (permalink)  
Old January 22nd, 2010, 02:57 PM
Imar's Avatar
Wrox Author
Points: 67,815, Level: 100
Points: 67,815, Level: 100 Points: 67,815, Level: 100 Points: 67,815, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,295
Thanks: 66
Thanked 1,441 Times in 1,421 Posts
Default

Hi Chris,

Are you sure this error is caused by code that is listening to the connection string you are changing? In other words, could it be that your site uses the LocalSqlServer connection string for Membership and roles, and that that connection string still targets .\SqlExpress? Can you see where you get the error?

>> (instead of default local system as I thought asp.net used the network service process, correct me if I am wrong

It depends. XP uses ASPNET, Vista, Server 2003 and 2008 first edition use Network Service while Windows 7 and Server 2008 R2 use a concept called application pool identity....

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
  #10 (permalink)  
Old January 23rd, 2010, 12:28 AM
Authorized User
 
Join Date: Jan 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

the application I am trying to run is the default application that I downloaded from the web site. Apart from changing the connection string in the web.config file I have not edited anything else.

I did find in the IIS DB connection setting that it was pointing to a .SQLExpress install, but changing that string to Data Source=Topher; Database=ASPNETDB; Integrated Security=True has not had any effect.

If I am only using Cassini as the .net server will it still interact with the local IIS?

Where else would I be able to find the LocalSQLServer connection string that the application is using?

In the database tools I have also tried changing the server and instance name to Topher with no effect either.

In terms of where I see the error, the error only occurs in the debugging tool within VS, and it keeps happening at the same line of code as follows:

Line 109: public virtual string Theme {
Line 110: get {
Line 111: return ((string)(this.GetPropertyValue("Theme")));
Line 112: }
Line 113: set {


The source file of this code is in the following location:

Source File: c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET Files\wroxunited\11274c8d\18b397c1\App_Code.2pftj1 wq.7.cs Line: 111

Another funy thing about this code is that on that particular page it goes through around 7 or 8 class declarations, the 'public virtual string them' is the last piece of code for the script but it does not generate the error for any of the previous declarations.

Hope this helps in some small way. Would it help if I reinstalled VS seeing as it is the only piece of software I have not reinstalled to get this code to work? It may reset any hidden defaults to SQLExpress if it can only see a local sql server on my machine?

Thanks again for your help and patience with this issue, truly appreciated.

Chris
Reply With Quote
Reply


Thread Tools
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
create setup file with sql desktop engine pkuchalia C# 0 May 4th, 2007 04:17 AM
BugBase - SQL 2005 Server setup tgueth BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 November 13th, 2006 07:47 AM
SQL Server results not shown correctly ps2goat ASP.NET 1.0 and 1.1 Professional 4 October 21st, 2005 03:24 PM



All times are GMT -4. The time now is 03:44 AM.


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