Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:35:37+00:00 2026-05-31T04:35:37+00:00

I’m working on an application that opens a database connection and retrieving data from

  • 0

I’m working on an application that opens a database connection and retrieving data from it to be showed to the user. Everything looks fine in the code of what I can see, but something is wrong because an exception gets thrown in the method below. I have placed a breakpoint at “conn.Open();” and it’s there the exception is thrown.

I have no idea how to find out what the actual error is and how to solve it, and hope to get some help here. The stack trace for the exception can be found here if it helps.

The exception is: System.ApplicationException: Error in the application

Thanks in advance!

the method that throws the exception:

public List<Movie> GetMovies() {

    var movieTitles = new List<Movie>(100);

    using (var conn = CreateConnection()) {
        try {
            var cmd = new SqlCommand("dbo.usp_GetMovies", conn);
            cmd.CommandType = CommandType.StoredProcedure;

            conn.Open();

            using (var reader = cmd.ExecuteReader()) {
                var movieIDIndex = reader.GetOrdinal("MovieID");
                var nameIndex = reader.GetOrdinal("Name");
                var yearIndex = reader.GetOrdinal("Year");
                var lengthIndex = reader.GetOrdinal("Length");
                var summaryIndex = reader.GetOrdinal("Summary");

                while (reader.Read()) {
                    movieTitles.Add(new Movie {
                        MovieID = reader.GetInt32(movieIDIndex),
                        Name = reader.GetString(nameIndex),
                        Year = reader.GetInt32(yearIndex),
                        Length = reader.GetInt32(lengthIndex),
                        Summary = reader.GetString(summaryIndex),
                    });
                }
            }
        }
        catch {
            throw new ApplicationException("An error occured!");
        }

    }

    movieTitles.TrimExcess();

    return movieTitles;
}

Heres the base class for the class containing the method above:

public abstract class DALBase {
    private static string _connectionString;

    static DALBase() {
            _connectionString = WebConfigurationManager.ConnectionStrings["NameOfTheDatabase_ConnectionString"].ConnectionString;
    }

    protected SqlConnection CreateConnection() {
        return new SqlConnection(_connectionString);
    }
}

from web.config:

  <connectionStrings>
    <add name="NameOfTheDatabase_ConnectionString" connectionString="Data Source=xxx.xx.xxx.x;Initial Catalog=The_Catalog;User ID=xxxxxx;Password=xxxxxx" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:35:38+00:00Added an answer on May 31, 2026 at 4:35 am

    Change

    throw new ApplicationException("An error occured!"); 
    

    to

    throw; 
    

    and you will get the actual exception and message.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.