Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 March 4th, 2009, 03:55 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default Database can't use SQL Server 2005.

I have SQL Server 2005 but for some reason it wont let me open the database file provided in the resources folder for chapter 11.

Pretty much having trouble with the first try it out it keeps telling me that to use sql server 2005 express it has to be functioning properly but I want to use the developer edition I have.

I know there isn't a problem with the developer editon as I have got a few databases and stored procedures working in it previously.
Reply With Quote
  #2 (permalink)  
Old March 4th, 2009, 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

Hi Will,

ASP.NET uses a SQL Server connection string called LocalSqlServer which, by default, points to (and thus insists on using) a SQL Server called .SqlExpress.

It's easy to use a different database server but you'll need to either override this connection string and point it to your server, or reconfigure services like Membership and Roles to use your database. Check out my reply here: Yellow screen of death when creating new user for some background and pointers to pages 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
  #3 (permalink)  
Old March 4th, 2009, 05:17 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

Haven't looked through that link yet but I have gone in the server explorer and changed the datasource from sqlexpress to \NETSDK which is what i have used for other databases and using windows authentication as that is what it is setup with.

Should I not even just be able to open the mdf file in sql server 2005 anyway?
Reply With Quote
  #4 (permalink)  
Old March 4th, 2009, 05:24 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

It depends on your connection stirng.

You should be able to open a database which has a connection string pointing to your own server.
However, separate files in the App_Data folder are typically opened in "user instance mode" which by default uses SQL Express.

Once you set up a connection to your own SQL server, it should be accessible from the Database Explorer.

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 March 4th, 2009, 05:43 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

Ok I read tha post and looked in the machine config file and it does say sql express so I changed it to Will as when I open sql server this is the login I have to use to connect successfully and view all my databases in that I have other logins such as Will\will parker and Will\ASPNET. So I am assuming here that I only need to put WILL as this seems to be the main one.

so i modified it to this
Code:
<add name="LocalSqlServer" connectionString="data source=.\WILL;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
In the server explorer when I double click the database connection I get the following error:

Quote:
Connections to SQL server files are require SQL Server express to function properly.
When I try to open the .mdf file from the resources folder directly using SQL Server 2005 I get this error:

There is no editor available for "filepathnamehere" make sure the application for the file type (.mdf) is installed.
Reply With Quote
  #6 (permalink)  
Old March 4th, 2009, 05:51 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

I think you're making too many changes at once which is always dangerous.

First of all, *don't* change Machine.config. As I explain in the book, simply <clear /> the connection strings and re-add the LocalSqlServer in your web site's *web.config* instead.

Also, is your server called Will? Then the instance name of SQL is not .\Will, but simply Will.

If I were (that's how I have it here as well) I'd do the following:

1. Install SQL Express die by side by the dev edition. Great for quick and dirty creation of new database driven web apps.

2. In sites running on a different database (either the Dev editon on (loca) or another one), override LocalSqlServer for the ASP.NET services and for your own connection stirngs.

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 March 4th, 2009, 06:12 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

Ok I put the machine config file back to say SQLEXPRESS.

If I wanted to connect to sql server 2005 dev edition then simply in the web config file i would have the following:

Code:
<connectionStrings>
<clear />
<add name="PlanetWroxConnectionString1" connectionString="Data Source=DatabaseServer;Initial Catalog="PlanetWrox;User Id=myusername; password=mypassword;" providerName="System.Data.SqlClient" />
where "PlanetWroxConnectionString1" is the name of my connection and could be called "PWCon" if I that is the name I had given it in the codebehind file?

"DatabaseServer" is the name of my database server in my case Will

"planetWrox" is the name of the database (.mdf) file

UserId and password are my username and password but I don't know what user name and password it is talking about?
Reply With Quote
  #8 (permalink)  
Old March 4th, 2009, 06:17 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

Did you read appendix B? It's all in there.

Your example uses SQL authentication where SQL manages the user name and password. Instead of that you could also use Integrated Secuirty.

Do yourself a favor, and read the full appendix B before you continue and seriously mess up your system. It provides you with a lot of detail and insights in how SQL Server authentication works.

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 March 4th, 2009, 06:43 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

Im an idiot. I hadn't attached the database...

Thanks again.
Reply With Quote
  #10 (permalink)  
Old March 4th, 2009, 07: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

Hahaha ;-) Glad it's working now..

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
Creating SQL Server database with Visual Basic 2005 Express kernan BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 4 December 30th, 2008 10:45 AM
reg conn to sql server 2005 from vb.net 2005.. veda SQL Server 2005 2 July 1st, 2008 12:16 AM
restore thePhile database with 2005 SQL Server ecarnews BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 4 July 2nd, 2007 12:58 PM
migrating from sql server 2000 to sql server 2005 abinashpatra SQL Server 2005 2 December 1st, 2006 03:45 PM
VB 2005 connect to server 2003 with SQL database Derek_05 Visual Basic 2005 Basics 3 September 20th, 2006 10:10 AM



All times are GMT -4. The time now is 07:16 PM.


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