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

  • Home
  • SEARCH
  • 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 8098219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:00:53+00:00 2026-06-05T22:00:53+00:00

After a while using the website, loading contents, etc.. this message shows Fill: SelectCommand.Connection

  • 0

After a while using the website, loading contents, etc.. this message shows “Fill: SelectCommand.Connection property has not been initialized”!
I think this is because the sql connection, but not sure… I’d like to know what can i do to prevent this, every time this happens i have to upload a file (SQL class, that make the connection) and the website starts to work again.

My SQL connection:

public class SQL
{

    SqlCommand comandos;
    public SqlConnection sql()
    {
        string Server = @"server"; 
        string Username = "user"; 
        string Password = "pass"; 
        string Database = "database";
        string ConnectionString = "Data Source=" + Server + ";";
        ConnectionString += "User ID=" + Username + ";";
        ConnectionString += "Password=" + Password + ";";
        ConnectionString += "Initial Catalog=" + Database;

        SqlConnection Connection = new SqlConnection();
        try
        {
            Connection.ConnectionString = ConnectionString;
            Connection.Open();
            return Connection;
        }
        catch (Exception)
        {
            if (Connection != null)
            {
                Connection.Dispose();
        }
        return null;
        }
    }

    public void FazerComando(string comando)
    {
        comandos = new SqlCommand(comando, sql());
        comandos.ExecuteNonQuery();
    }

    public DataTable Execute(string comando)
    {
        SqlDataAdapter SQLDataAdapter = new SqlDataAdapter(comando, sql());
        DataTable dtResult = new DataTable();
        SQLDataAdapter.Fill(dtResult);
        return dtResult;
    }
}
  • 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-06-05T22:00:54+00:00Added an answer on June 5, 2026 at 10:00 pm

    This might be related to your problem, but in any case, it’s something that should be addressed: You’re not disposing your connections when you’re done with them. You should use using:

        public void FazerComando(string comando)
        {
            using (var conn = sql())
            {
                comandos = new SqlCommand(comando, conn);
                comandos.ExecuteNonQuery();
            }
        }
        public DataTable Execute(string comando)
        {
            using (var conn = sql())
            {
                SqlDataAdapter SQLDataAdapter = new SqlDataAdapter(comando, conn);
                DataTable dtResult = new DataTable();
                SQLDataAdapter.Fill(dtResult);
                return dtResult;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using WebViewClient to browse urls using the emulator. after a while (cannot tell
After using PHP for a while now, I've noticed that not all built-in PHP
I am using Struts application while running welcome page is run successfully after that
I'm using crystal reports to build reports, everything is ok while development. But after
I found out after a while that a component used on my website had
This problem is beginning to annoy. After my machine (Vista Ultimate) has been up
I am trying to connect to a website. After While authentication is successful, I
I added a launch image to my iPhone app in Xcode, but after while,
After a while I figured out I could bind Shark to the process of
Well after a while of scratching my head and going huh? trying to figure

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.