Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution 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 October 31st, 2006, 12:19 PM
Authorized User
 
Join Date: Feb 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi englere.
I commented code-line dr.Close(); so after build of task I got error: Use of unassigned local variable 'dr'. Then task Test was executed the result looks like:
_________________________________________
Exception: Login failed for user 'ThePhileUser'.

Press Return ...

______________________________________________

Debug:
Quote:
quote:
'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\msco rlib.dll', No symbols loaded.
'Test': Loaded 'C:\Documents and Settings\EUGZ\My Documents\Visual Studio Projects\Test\bin\Debug\Test.exe', Symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system.data\1.0.5000.0__b 77a5c561934e089\system.data.dll', No symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c 561934e089\system.dll', No symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system.enterpriseservices \1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseser vices.dll', No symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system.enterpriseservices \1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseser vices.thunk.dll', No symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system.xml\1.0.5000.0__b7 7a5c561934e089\system.xml.dll', No symbols loaded.
The program '[1664] Test.exe' has exited with code 0 (0x0).
I will wait other replays. Thanks a lot for your help.

 
Old October 31st, 2006, 04:49 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can get around the "dr" error by using this code:
old:
  SqlDataReader dr;
new:
  SqlDataReader dr = null;

And you should change your finally clause:

   if (dr != null)
     dr.Close();
   if (con.State == ConnectionState.Open)
     con.Close();

And change the line that shows the exception:

Console.WriteLine("Exception: " + ex.Message + " Exception type: " + ex.GetType().ToString());


But you weren't able to connect to your database, so you need to figure out the right connection string. Did you plug in your own info in the Connection String? You can visit ConnectionStrings.com to see if they can help you.

To make it easier for you, here's the whole program with the changes:

using System;
using System.Data;
using System.Data.SqlClient;

namespace ConnectTest
{
  class ConnectTestClass
  {
    static void Main(string[] args)
    {
      try
      {
        // Plug in your own connection string below:
        string conStr = @"server=(local);database=ThePhile;uid=ThePhileUse r;pwd=password;";
        SqlConnection con = new SqlConnection(conStr);
        con.Open();

        Console.WriteLine("Tables in the database:");

        // This SQL lists the tables in the DB
        String sqlStr = "select name from sysobjects where type='U'"
          + " and name not like 'dt%' order by name";

        SqlCommand cmd = new SqlCommand(sqlStr, con);
        SqlDataReader dr = null;
        try
        {
          dr = cmd.ExecuteReader();

          while (dr.Read())
          {
            Console.WriteLine("{0}", dr.GetString(0));
          }
        }
        finally
        {
          if (dr != null)
            dr.Close();
          if (con.State == ConnectionState.Open)
            con.Close();
        }
      }
      catch (Exception ex)
      {
         Console.WriteLine("Exception: " + ex.Message + " Exception type: " + ex.GetType().ToString());
      }
      Console.Write(Environment.NewLine + "Press Return ...");
      Console.ReadLine();
    }
  }
}



 
Old October 31st, 2006, 07:19 PM
Authorized User
 
Join Date: Feb 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi englere
In your code I changed uid=ThePhileUser to uid=sa.
string conStr = @"server=(local);database=ThePhile;uid=sa;pwd=pass word;";
It is like I have in my config files. Is that correct?

I show all my ConnectionString config files of project ThePhile:

Web.config
<sessionState
   mode="InProc"
   stateConnectionString="tcpip=172.18.56.50"
   sqlConnectionString="data source=(local);uid=sa;password="
   cookieless="false"
   timeout="20"
/>

Accounts.config
<ConnectionString>server=(local);database=thePhile ;uid=sa;pwd=;</ConnectionString>

AdsManager.config
<ConnectionString>server=(local);database=ThePhile ;uid=sa;pwd=;</ConnectionString>

Forums.config
<ConnectionString>server=(local);database=ThePhile ;uid=sa;pwd=;</ConnectionString>

MailingLists.config
<ConnectionString>server=(local);database=ThePhile ;uid=sa;pwd=;</ConnectionString>

NewsManader.config
<ConnectionString>server=(local);database=ThePhile ;uid=sa;pwd=;</ConnectionString>

Then I rebuild and execute your code.

Result after execution:
__________________________________________________ _________________________
Exception: Login failed for user 'sa'. Exception type: System.Data.SqlClient.SqlException

Press Return ...
__________________________________________________ _________________________

Debug
Quote:
quote:'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\msco rlib.dll', No symbols loaded.
'Test': Loaded 'C:\Documents and Settings\EUGZ\My Documents\Visual Studio Projects\Test\bin\Debug\Test.exe', Symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system.data\1.0.5000.0__b 77a5c561934e089\system.data.dll', No symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c 561934e089\system.dll', No symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system.enterpriseservices \1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseser vices.dll', No symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system.enterpriseservices \1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseser vices.thunk.dll', No symbols loaded.
'Test.exe': Loaded 'c:\windows\assembly\gac\system.xml\1.0.5000.0__b7 7a5c561934e089\system.xml.dll', No symbols loaded.
The program '[6092] Test.exe' has exited with code 0 (0x0).
I will wait other replays. Thanks a lot for your help.


 
Old October 31st, 2006, 10:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know how to help you anymore. I don't know what your account info is, and this is clearly a connection problem. You should see if a friend can help because someone has to sit down at your computer and figure out how your Sql Server is set up. You should probably get a beginners book on Sql Server, also. This project assumes you know how to use it.

Eric

 
Old November 14th, 2006, 02:27 PM
Authorized User
 
Join Date: Feb 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi englere.
After reinstallation ThePhile project I got new result. May be with that error will easy to fix the problem.

Thanks.
 
Quote:
quote:Error
Quote:

--------------------------------------------------------------------------------
An unexpected error has occurred on this page.The system administrators have been notified.

The error occurred in:
http://localhost/thephileVB/Default.aspx

Error Message:
Access to the path "C:\wrox\ThePhileVB\Config\Polls.Config" is denied.


Error Stack:
System.UnauthorizedAccessException: Access to the path "C:\wrox\ThePhileVB\Config\Polls.Config" is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String str)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at Wrox.WebModules.Polls.Configuration.ModuleConfig.G etSettings() in C:\wrox\ThePhileVB\WebModules\Polls\Polls.Configur ation\ModuleConfig.vb:line 35
   at Wrox.WebModules.Polls.Business.Question.GetCurrent Id() in C:\wrox\ThePhileVB\WebModules\Polls\Polls.Business \Question.vb:line 224
   at Wrox.WebModules.Polls.Web.Controls.User.Poll.DataB ind() in C:\wrox\ThePhileVB\WebModules\Polls\Poll.ascx.vb:l ine 260
   at Wrox.WebModules.Polls.Web.Controls.User.Poll.Page_ Load(Object sender, EventArgs e) in C:\wrox\ThePhileVB\WebModules\Polls\Poll.ascx.vb:l ine 62
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain()








Similar Threads
Thread Thread Starter Forum Replies Last Post
ThePhile.sln project installation & Execution help monir75 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 October 16th, 2006 08:18 AM
Installation for VB project pavel Pro VB 6 0 April 13th, 2006 09:32 AM
Installing thePhile Database help glabana BOOK: ASP.NET Website Programming Problem-Design-Solution 2 January 11th, 2006 12:19 PM
Error while running/executing project thePhile seetha_l BOOK: ASP.NET Website Programming Problem-Design-Solution 0 June 11th, 2004 11:31 AM
keep getting an error with ThePhile ar3ol BOOK: ASP.NET Website Programming Problem-Design-Solution 15 February 4th, 2004 01:19 PM





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