Wrox Programmer Forums
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 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 17th, 2003, 01:07 PM
Authorized User
Join Date: Sep 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 12 SQL Server Access

In this useless wrox press book I'm currently being tortured by there is the script below, it is suppose to simply open and close a connection to SQL Server 2000 but it doesn't work:

<%@Import namespace="System.Data"%>
<%@Import namespace="System.Data.SqlClient"%>
<script runat="server" language="c#">
void Page_Load()
      string strConnection = "user id=sa;password=;";
      strConnection += "initial catalog=northwind;server=MIKE;";
      strConnection += "Connect Timeout=30";

      data_src.Text = strConnection;

     SqlConnection objConnection = new SqlConnection(strConnection);

          con_open.Text = "Connection opened successfully.<br />";
          con_close.Text = "Connection closed <br />";
     catch (Exception e)
         con_open.Text = "Connection failed to open.<br />";
         con_close.Text = e.ToString();
<h4>Testing the data connection <asp:label id="data_src" runat="server" /></h4>
<asp:label id="con_open" runat="server" /><br />
<asp:label id="con_close" runat="server" /><br />

It returns the following error:

System.Data.SqlClient.SqlException: Login failed for user 'sa'. at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction) at System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at ASP.sql_connection_aspx.Page_Load()

The book also states that if the code doesn't work we should try replacing the user id and password line with this line:

string strConnection = "Integrated Security=SSPI;";

But this doesn't work either. So needless to say I have no idea what's wrong, can anyone help as unfortunately the psychic powers Wrox Press clearly believe I possess aren't working. I have no idea whether this should work straight out like this or whether some configuration or something needed to be done first. I'm totally stuck, please help.

Old September 20th, 2003, 08:59 AM
Authorized User
Join Date: Sep 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts

Ok, I have the answer so there is no need to respond. If anyone is interested you can't use the sa account if you're using SQL Server 2000 (as I am), as a password is automatically generated for this account by SQL Server 2000 (and I have no idea what it is). In previous SQL Server versions this wasn't the case. So if you're using SQL Server 2000 you should create a new user, and use that user id and password in place of the one in the example.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 12 - Access to Northwind.mdb Luke24 BOOK: Beginning ASP.NET 1.0 3 November 13th, 2009 07:55 PM
Chapter 12 SQL File? Any SQL files? ripcurlksm BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 20th, 2008 06:49 PM
Getting Chatper 12 to work with Sql Server 2000 tperri75 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 11 August 11th, 2006 12:06 PM
Beginning Access VBA Chapter 12 Comet_0891 BOOK: Beginning Access 2003 VBA 0 June 6th, 2005 11:42 PM

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