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 7027415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:14:39+00:00 2026-05-28T00:14:39+00:00

Can I get a list of issues with the code below, and fixes? string

  • 0

Can I get a list of issues with the code below, and fixes?

 string ProgramID = HttpContext.Current.Session[CommonFunctions.myNGconnectSessionVars.ProgramId].ToString();
            SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["MyNGConnectDashBoardConnectionString"].ToString());
            SqlCommand cmd = new SqlCommand();
            DataSet ds = new DataSet();
            try
            {
                cmd.Connection = con;
                cmd.CommandTimeout = 900;
                cmd.CommandText = "dsb_GetSubscriptionDetailsForSubscriber_ForValidations";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@GPCustomerID", strGPCustomerID);
                cmd.Parameters.AddWithValue("@UserName", strUserName);
                cmd.Parameters.AddWithValue("@ServerName", ConfigurationManager.AppSettings["ServerName"].ToString());
                //code changed by sushma 3/22/2011 as new tab added for reach
                //cmd.Parameters.AddWithValue("@ProgramID", CommonFunctions.ProgramID);
                cmd.Parameters.AddWithValue("@ProgramID", ProgramID);
                cmd.Parameters.AddWithValue("@IsTeacher", blnIsTeacher);
                // cmd.CommandTimeout = 0;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }

            return ds;
  • 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-28T00:14:40+00:00Added an answer on May 28, 2026 at 12:14 am

    Here are some immediate improvements

    Use using statement rather than try/finally for the connection management

    Use throw and not throw ex to re-throw the exception, better yet you can just remove the catch and re-throw

    There is no need to call Parameters.Clear on the command that you just instantiated.

    And finally, if you are going to do a lot of DB work, I would suggest you look at using a lightweight ORM.

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

Sidebar

Related Questions

I'm using the code below to get a cron list but only thing I
I can get a list of running threads from Process.GetCurrentProcess().Threads, but I need to
You can get a list of databases using PRAGMA database_list or a list of
There's a function in PHP where you can get a list of the user
I have one table having ID and other attributes. How can I get list
I am building a pretty basic form app. I can get a list of
Is there any debugging options built-in in the Xlib (libX11.so)? Can I get list
Can I get a list of the playlists and songs in each playlist in
How can I get the list of available databases on a SQL Server instance?
How can I get a list of the IP addresses or host names from

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.