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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 6th, 2006, 08:04 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connection problems with Full Sql Server

I've see this come up a couple of times so I thought I would post an easy fix.
Step one Attach the databases. (if you don't know how to attach a database then please post a reply)
Step two change the <connectionStrings> section of the web config that is supplied from wrox. It should be around line 20.
Use this instead:
 <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer"
connectionString="Data Source=localhost;Initial Catalog=ASPNETDB;Integrated Security=True"
         providerName="System.Data.SqlClient"/>
     <add name="WroxUnited"
         connectionString="Data Source=localhost;Initial Catalog=WroxUnited;Integrated Security=True"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

I hope this helps.

  #2 (permalink)  
Old November 6th, 2006, 08:03 PM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the headsup. If I use your connectionString as written, asp can't find the data source. I need the whole pathname in the connectionSTring. Where do you have your data located, and does that data change after chapter 3? It would be nice to store it in the c: and modify all conections strings to all chapters to point there rather than that having that long path name.

  #3 (permalink)  
Old November 8th, 2006, 06:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Banbury, , United Kingdom.
Posts: 105
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to DanM
Default

enzoinbath,

I think you might be getting mixed up here. These connection strings work if you have a full installation of SQL Server, have created the databases inside that and are connecting to them. In which case, the only problem you might have is that you've called your SQL Server installation other than the default of 'localhost'.

If you're running SQL Server Express then you should use the connection strings in the book. In which case, if you leave the mdb file for your database in the app_data folder of your website, you should be able to use the abbreviation AttachDbFilename=|DataDirectory|\mydatabase.mdf for example

Dan

Dan Maharry
Read the feed at http://feeds.feedburner.com/dansarchive
  #4 (permalink)  
Old December 10th, 2006, 01:36 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Lightwaver
 I've see this come up a couple of times so I thought I would post an easy fix.
Step one Attach the databases. (if you don't know how to attach a database then please post a reply)
Step two change the <connectionStrings> section of the web config that is supplied from wrox. It should be around line 20.
Use this instead:
 <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer"
connectionString="Data Source=localhost;Initial Catalog=ASPNETDB;Integrated Security=True"
         providerName="System.Data.SqlClient"/>
     <add name="WroxUnited"
         connectionString="Data Source=localhost;Initial Catalog=WroxUnited;Integrated Security=True"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

I hope this helps.

I would just like to thank you so much :) I registered just to make this post as I have been referencing this forum for hours in order to solve this problem #61514; I luckily found this post which INSTANTLY solved the issue.

Good work mate.


Paul
  #5 (permalink)  
Old December 13th, 2006, 11:13 PM
Registered User
 
Join Date: Dec 2006
Location: Honolulu, HI, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've tried to do this a few ways, even tried this suggestion, but after setting up the db on a remote sql server, I still cannot connect. I'm getting a problem connecting. I think it's a problem with security access the db. What are/should be the security settings/privileges?

I have remote access to that sql server box setup properly.

Thanks.

  #6 (permalink)  
Old December 13th, 2006, 11:49 PM
Registered User
 
Join Date: Dec 2006
Location: Honolulu, HI, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm getting an error on this line,
    return ((string)(this.GetPropertyValue("Theme")));

Both of the connection strings have this sub-string.
connectionString="Data Source=SqlSvrName;Initial Catalog=ASPNETDB; ID=sa; Password=SomeSpecialPwd"

Please, nothing about the sa account, my first problem is accessing the sql server and getting this to run, then I'll worry about security permissions. I know I can see/query that box cause I can setup a connection in the Server Explorer and use that, so I know the remote access exception is true, but not linked to the sql server not accepting remote connections.

Thanks.

  #7 (permalink)  
Old December 13th, 2006, 11:58 PM
Registered User
 
Join Date: Dec 2006
Location: Honolulu, HI, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm trying, you have to give me credit for that!

I just created a testing web app, created and tested a webpage to bring back the news, so I know I can do this. But when I cut'n'paste the connectionstring portion of that web.config into the WroxUnited website, it still won't work.

Here's what I got from my latest testing.
connectionString="Data Source=SqlServerName;Initial Catalog=WroxUnited;Persist Security Info=True;User ID=sa;Password=SomeSpecialPwd"

  #8 (permalink)  
Old December 28th, 2006, 08:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Banbury, , United Kingdom.
Posts: 105
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to DanM
Default

Hi Flip,

OK, it looks like you've got a couple of issues there.
First of all, I just want to check with you which version of the code you are trying to set up. Is it the Vb or the C# code download? Is the full site code or one of the chapter start or end directories of code?

Next up - the connection string. If you've just copied the connection string from a web site that successfully connects to the database in Wrox United and wrox united doesn't, then it may not be the connection string. I'm guessing you're using IIS rather than the ASP.NET development server, so open the properties for WroxUnited in IIS and switch to the ASP.NET tab. You should be able to click the ASP.NET Configuration button. The resulting dialog should show all the connection strings that WroxUnited has configured for it. Check that the connection strings there are correct as well. The site could be inheriting connection strings from IIS that are confusing it.


What's the error you are getting on the following line?

I'm getting an error on this line,
    return ((string)(this.GetPropertyValue("Theme")));

Usually, errors occur on this line because the code for themes (themes.cs I think) isn't present in the app_code directory of the site so ASP.NET reads web.config which says that user profiles should contain a theme but then the code isnt present to tell it how to get one \ what a theme is. Two solutions here are either to comment out the relevant bit of web.config concerning themes or to just add theme.cs to the app_code directory.

I hope that helps

Dan

Dan Maharry
Read the feed at http://feeds.feedburner.com/dansarchive
  #9 (permalink)  
Old January 4th, 2007, 03:16 PM
Authorized User
Points: 174, Level: 3
Points: 174, Level: 3 Points: 174, Level: 3 Points: 174, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by DanM
I'm getting an error on this line,
    return ((string)(this.GetPropertyValue("Theme")));

Usually, errors occur on this line because the code for themes (themes.cs I think) isn't present in the app_code directory of the site so ASP.NET reads web.config which says that user profiles should contain a theme but then the code isnt present to tell it how to get one \ what a theme is. Two solutions here are either to comment out the relevant bit of web.config concerning themes or to just add theme.cs to the app_code directory.

Dan Maharry
Dan, should that be themes.vb for vb projects? When I add Themes.cs to the app_code directory I get a compile error in Cassini. And can I just add a blank themes file, or does it have to have some code in it? If so, I don't know anything about how to code it at this point.

I used Cassini to see if it gave the same errors as IIS, and it does. I'm using SQL Server Standard and VS Professional, and I can't get beyond this themes error. Before, when I had SQLEXPRESS and Vis. Studio Express, I had it all working.

Also, can someone go through the proper steps for attaching the database(s). I rename the databases to WroxUnited and ASPNETDB because they want to attach with a long files name like "g:\begaspnet2\finalapplication..." etc. Then I go to properties and change the owner to "sa". I also gave Network Service the write permission for the app_data folder and set up the virtual directory in sqlXml as the book states. (However, I had previously set up the WroxUnited Virtual directory with SQLXML when I had SQL EXPRESS and VS WEB EXPRESS. Should I delete the virtual directory in IIS and start over now that I have STANDARD and PROFESSIONAL?)
Thanks for any help!

Brian

Sincerely,
Brian
  #10 (permalink)  
Old January 4th, 2007, 03:21 PM
Authorized User
Points: 174, Level: 3
Points: 174, Level: 3 Points: 174, Level: 3 Points: 174, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's the exception I get after I've added the blank Themes.vb to the app_code directory (see below).

But also, I wanted to check that I used Lightwaver's instruction correctly - I used my SQL Server "instance" name where Lightwaver says:

<remove name="LocalSqlServer"/>
    <add name="LocalSqlServer"

so mine says:
<remove name="MSSQLSERVER"/>
    <add name="MSSQLSERVER"


System.Data.SqlClient.SqlException was unhandled by user code
  Class=20
  ErrorCode=-2146232060
  LineNumber=0
  Message="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: 25 - Connection string is not valid)"
  Number=87
  Server=""
  Source=".Net SqlClient Data Provider"
  State=0
  StackTrace:
       at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup)
       at System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
       at System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at System.Web.DataAccess.SqlConnectionHolder.Open(Htt pContext context, Boolean revertImpersonate)
       at System.Web.DataAccess.SqlConnectionHelper.GetConne ction(String connectionString, Boolean revertImpersonation)
       at System.Web.Profile.SqlProfileProvider.GetPropertyV aluesFromDatabase(String userName, SettingsPropertyValueCollection svc)
       at System.Web.Profile.SqlProfileProvider.GetPropertyV alues(SettingsContext sc, SettingsPropertyCollection properties)
       at System.Configuration.SettingsBase.GetPropertiesFro mProvider(SettingsProvider provider)
       at System.Configuration.SettingsBase.GetPropertyValue ByName(String propertyName)
       at System.Configuration.SettingsBase.get_Item(String propertyName)
       at System.Web.Profile.ProfileBase.GetInternal(String propertyName)
       at System.Web.Profile.ProfileBase.get_Item(String propertyName)
       at System.Web.Profile.ProfileBase.GetPropertyValue(St ring propertyName)
       at ProfileCommon.get_Theme() in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET Files\wroxunited\2112705c\14c1a696\App_Code.ldrbhd 6h.7.vb:line 114
       at Wrox.Web.GlobalEvents.ThemeModule.app_PreRequestHa ndlerExecute(Object Sender, EventArgs E) in C:\Websites\WroxUnited\App_Code\ThemeModule.vb:lin e 30
       at System.Web.HttpApplication.SyncEventExecutionStep. System.Web.HttpApplication.IExecutionStep.Execute( )
       at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously)


Sincerely,
Brian
 


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
cannot attach to databases with SQL Server Full dhx10000 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 October 30th, 2007 04:28 PM
SQL connection problems username passwords beatniks BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 6 August 16th, 2006 11:45 AM
SQL Server - System log full Jane SQL Server 2000 3 December 23rd, 2004 10:10 PM
Connection with sql server arshad mahmood VB Databases Basics 1 June 19th, 2003 10:53 PM



All times are GMT -4. The time now is 04:29 AM.


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