Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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
 
Old September 16th, 2006, 12:19 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default I can't connect to the sql 2005 developer DB

I am working on the Online Diary Project. I have modified the actual connection in databse explorer to use sql 2005 (not express)and modified the connection string in the web.config. This is the connection string:

 <add name="DiaryDBConnectionString" connectionString="Data Source=THEO;Initial Catalog=Diarydb.mdf;Integrated Security=True"
   providerName="System.Data.SqlClient" />

Can someone tell me where I am going wrong, please?

I am guessing that it is something in ASP that I am missing. Thanks

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)


 
Old September 16th, 2006, 01:21 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

How is your SQL Server installation called? And is it located on the same machine as your web app?

Can you give us a bit more details about your setup?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old September 16th, 2006, 02:35 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, thanks for responding.

Both, the web app and DB are on the same machine. I am using windows authentication.

I just added a line including impersonation- - I get the same results.

I have run other web/wDB apps before on this machine. I a version 4 of DNN running.

Here is my web.config. Maybe it will help.

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <connectionStrings>
  <add name="DiaryDBConnectionString" connectionString="Data Source=THEO;Initial Catalog=Diarydb;Integrated Security=SSPI"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
 <system.web>
   <identity impersonate="true" />
   <roleManager enabled="true" />
  <authentication mode="Forms"/>
        <compilation debug="true"/></system.web>
 <system.net>
  <mailSettings>
   <smtp from="system@diary-system.com">
    <network host="localhost" password="" userName= ""/>
   </smtp>
  </mailSettings>
 </system.net>
</configuration>



 
Old September 16th, 2006, 02:42 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have attempted the connection on both the IIS and built in web server.

 
Old September 16th, 2006, 05:35 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

After looking a little close to this problem, it seems that my problem is with the aspnetdb.mdf. I can see how to move the db to sql 2005 but I can't see where to call it from. All along I thought that the diarydb was not connecting, but I think now that the problem is aspnetdb.mdf. I really need some direction now, please. Thanks

 
Old September 17th, 2006, 05:40 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look at this article: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=395

It explains how to configure ASP.NET apps and SQL Server to allow your apps to use a commercial version of SQL Server instead of the Express Edition. I think it provides all the guidance you may need.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Shadowplay (RCA Unreleased Album Session - Arrow Studios, Manchester, May 1978) by Joy Division (Track 7 from the album: Heart And Soul (CD 3 - Studio Rarities & Unreleased)) What's This?
 
Old September 17th, 2006, 01:07 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You know that may be some of the problem, but I don't think that it is the central problem.  In the online diary application, you must first login before you can do anything.  The Aspnetdb.mdf controls the login, and the connection string for this login is to sql express, not sql 2005!  I believe that the connection string for this paticular db is in the machine.config file, because it is certainly not in web.config. Now this change is going to trigger a series of changes.  May I recommend that you go to your online coding depository and provide a version of the code for sql 2005 databases. This would be the quickest way to solve this problem. Then once I am sure that I have a correct connection string to sql 2005, I can then focus my attention on ASP permissions.  I don't want to rant, buy why would you write a book based on sql express (and exempt sql 2005) when the developer edition of SQL 2005 cost less than $50. With this bargin of a price, I can't understand why anyone would use sql express.  Thanks
 
Old September 17th, 2006, 02:24 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This code is in the machine.config file. It points the aspnetdb.mdf to sql express. This code appears to control all of the membership and role providers. Should I manually change this? And, once I change it, will it correctly point to the aspnetdb.mdf. Will this connection string work: connectionString="Data Source=THEO;Initial Catalog=aspnetdb.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />?
Do I have to reclocate the actual databases to some other directory, also? How did this code get here? This is starting to look like a lot of work. Thanks

<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.data>
    <DbProviderFactories>
      <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory , System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </DbProviderFactories>
  </system.data>
  <system.web>
    <processModel autoConfig="true" />
    <httpHandlers />
    <membership>
      <providers>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
      </providers>
    </membership>
    <profile>
      <providers>
        <add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </providers>
    </profile>
    <roleManager>
      <providers>
        <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider , System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </providers>
    </roleManager>

 
Old September 17th, 2006, 03:19 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi again,

Why would anyone spend $50 if you can get most of SQL Server for free?

Anyway, that's not really the point here. The thing is, there is no "code for SQL Server 2005" and "code for the Express Edition". Switching between the two is a matter of configuration.

The first article I linked to fixes issues with your own databases that run under SQL Server. Did you see / follow the link from that article to the blog post by Scott Guthrie? It explains how to configure the ASP.NET services (like Membership) to work with a real version of SQL Server. You can find the post here: http://weblogs.asp.net/scottgu/archi...25/423703.aspx

Basically, all you need to do comes down to this:

1. Configure a database for ASP.NET 2 services.

2. "Clear" existing connection strings from the config hierarchy

3. Add a new one that points to your server.

That's it. No messing around with machine config, no special code and so on. The article explains in detail what you need to do.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old September 17th, 2006, 07:55 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Fine, I guess you didn't like my recommendation about providing code for both db scenarios.  Actually I still think that it is a pretty good idea and you should consider it, for had I known when I bought the book that it was based on sql express, I would not have bought it.  I bought the book on Amazon.com and this parcel of information wasn't revealed.
 Â
Re your position about getting most (but not all) of something, that's pretty close to where I am with the code in your book.  You have provided most of what I need, but not all, yet that very small missing part is making all the difference in maybe having had an app running two days ago vs still not running, while I still rummage throught the internet for some cryptic instructions on how to re configure an application from the economy version to the standard comercial version.

Furthermore, I am speaking with some degree of experience about the difference in the two versions: I used sql express for 4 months on one of my three machines and was constantly running into work that it couldn't do, but that it predecessor, sql 2000 could. Since upgrading to sql 2005 this has not been an issue.  There is unequivocally no comparision in the difference between using express and the full blown developer edition: I repeat no comparison!

So far this whole endeavor has been a real dissappointment. Now, the silver lining to all of this is that I am getting very granular look a configuring different databases.  Not that I wanted to or that I should have ever needed to.   It looks like I am on my own with this problem and will have make a decision whether to continue with the other projects in the book or move on to another text.

In closing please take all of this in the constructive spirit in which I have offered it.Thanks again, JB





Similar Threads
Thread Thread Starter Forum Replies Last Post
connect ing to sql 2005 twisted f8 Visual Basic 2005 Basics 1 September 13th, 2007 09:47 PM
connect to SQL EXPRESS 2005 angelboy C# 2005 0 June 8th, 2007 01:34 PM
SQL Server 2005 using Visual Web Developer carswelljr SQL Server 2005 1 September 14th, 2006 12:43 PM
SQL Server 2005 Express with Visual Web Developer steffteo SQL Server 2005 1 March 19th, 2006 04:28 PM
connect to sql db jopay Visual C++ 0 January 12th, 2005 05:17 PM





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