Wrox Programmer Forums
|
BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Special Edition by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, Srinivasa Sivakumar; ISBN: 9780470041789
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 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 July 19th, 2011, 08:47 AM
Authorized User
 
Join Date: Dec 2007
Posts: 48
Thanks: 4
Thanked 0 Times in 0 Posts
Default Unable to connect to SQL database

Hi,

I'm working listings 20-5 and 20-6, and keep getting the following error:

Unable to connect to SQL database 'Northwind' for cache dependency polling

I have run the aspnet_regsql.exe command to enable cacheing for both tables and the database. When I use the -lt option, both tables (Customers and Products) are listed. But when I open the AspNet_SqlCacheTablesForChangeNotification table, it is empty.

Here is my code:

<code>

aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="SqlCacheInvalidation.aspx.cs"Inherits="SqlCacheDependencies"Trace="true" %>
<%
@OutputCacheDuration="3600"VaryByParam="none"SqlDependency="Northwind:Customers" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
htmlxmlns="http://www.w3.org/1999/xhtml">
<
headrunat="server">
<title>Sql Cache Invalidation</title>
</
head>
<
body>
<formid="form1"runat="server">
<div>
<asp:LabelID="Label1"runat="server"></asp:Label>
<asp:GridViewID="GridView1"runat="server">
</asp:GridView>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:AppConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:AppConnectionString1.ProviderNam e %>"SelectCommand="SELECT * FROM [Customers]">
</asp:SqlDataSource>
</div>
</form>
</
body>
</
html>

code behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
publicpartialclassSqlCacheDependencies :
System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
Label1.Text =
"Page created at " + DateTime.Now.ToShortTimeString();
}
}

web.config

<connectionStrings>
<
removename="LocalSqlServer"/>
<
addname="LocalSqlServer"connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|aspnet.mdf;Integrated Security=True;User Instance=True"providerName="System.Data.SqlClient"/>
<
addname="AppConnectionString1"connectionString=
"data source=tommagaro-pc\sqlexpress; database=Northwind; Persist Security info=false"
providerName="System.Data.SqlClient"/>
</
connectionStrings>
<
system.web>
<
caching>
<
sqlCacheDependencyenabled="true">
<
databases>
<
addname="Northwind"connectionStringName="AppConnectionString1"
pollTime="500"/>
</
databases>
</
sqlCacheDependency>
</
caching>

</code>

Has anyone else encountered this problem?


The flashman
__________________
Thomas G Magaro
 
Old July 19th, 2011, 10:58 AM
Authorized User
 
Join Date: Dec 2007
Posts: 48
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Never mind. I had the -et out of place.
__________________
Thomas G Magaro





Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to connect sql server 2005 priyan.viji Internet Information Services 1 December 16th, 2008 11:57 AM
Unable to connect to pubs database... help! scottkhughes BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 1 September 10th, 2008 08:35 AM
How to connect SQL Database eapsokha Classic ASP Professional 1 March 10th, 2004 04:18 AM
Connect to sql database kale_tushar Pro VB 6 8 September 8th, 2003 03:27 AM
[000] Unable to connect to server 'SERVER\SQL'; SQ ctanchan SQL Server 2000 1 August 15th, 2003 07:18 AM





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